Fader switch uses inexpensive controller
Customizing a model or a simulator with a bit of illumination is a nice touch. Rather than a simple on or off, you can add a touch of both refinement and control to your display with fading light. Employing a Microchip 10F20x microcontroller, the circuit in Figure 1 provides dual-rate fader control for a push-on/push-off switch, a momentary pushbutton switch, or a simple on/off SPST (single-pole/single-throw) switch. The circuit monitors and debounces the switch and generates a multiple-cycle, 470-Hz, PWM (pulse-width-modulated) output to drive LEDs or incandescent lamps. The circuit includes a Maxim MAX16823 IC that drives multiple LEDs.
The microcontroller produces 64 linear steps of a PWM signal between 0 and 100% duty cycle. The controller maintains each pulse width for a variable number of cycles employing a table in the assembly code (Listing 1). You can modify the code to build profiles of LEDs or incandescent lamps by applying a settable dwell time to each PWM step. The code contains two tables to set fast- and slow-fade characteristics. The fade values provide a cubed index that produces a 3-to-1 fade ratio (Figure 2). Using the final state of the output at Pin 3 of the 10F200, you access the tabled number of dwell cycles from the first table entry to the last for a high final state or from the last entry to the first to arrive at the final low state.
Fade-transition timing is user-selectable for either a 3- or a 9-second period. The circuit periodically samples both the fade rate and button or switch mode, allowing you to multiplex the design or use it in multiple configurations. The mode control is on Pin 5 of the controller, and the rate control is on Pin 4. The application exploits the controller's internal 4-MHz clock and the configurable pullup resistors on the monitored inputs. A prototype of the circuit uses a 10F20x in an eight-pin DIP, but the controller is also available in a smaller SOT-23 package.