Rainbow LED indicates voltage with color
David Prutchi, Impulse Dynamics, Haifa, Israel - December 7, 2004
Meters that indicate analog levels via a moving-pointer meter, a numeric display, or a column of LEDs typically occupy considerable panel area and require more than a casual glance to read. An indicator lamp or LED takes little space but indicates only an on or off condition. However, an unobtrusive LED that changes color as a function of a measured value would enable an observer to easily assess the measurement.
The circuit in Figure 1 comprises IC1, a Microchip PIC12F675 microcontroller driving IC2, a Kingbright AAF5060PBESEEVG "rainbow" indicator that contains three ultrabright LED chips (red, green, and blue) within one package. Modulating each LED's duty cycle produces all of the perceivable colors of the visible spectrum, including white light. Listing 1 contains a PIC program for the PicBasic Pro compiler, which is available from MicroEngineering Labs Inc (www.melabs.com). This program converts a 0 to 5V input applied to Pin 3 of IC1 to an 8-bit digital value that corresponds to a perceived color containing certain amounts of red, blue, and green.
Under control of a PWM routine, each LED flashes for an interval proportional to its corresponding content of red, green, or blue. During each PWM frame, an LED die receives power for as many as 14 steps per frame as the color map of Figure 2 shows. Although not all LEDs are necessarily simultaneously illuminated, the eye's slow response integrates their output to create the illusion of a change in intensity proportional to the duty cycle. The RGB-encoding function in Listing 1 assumes that the analog input to IC1 has a zero-signal offset of 2.5V, which switches all LEDs off. "Cool" colors (shades of blue, purple, and aqua) denote an input in the 0 to 2.5V range, and "hot" colors (shades of red, orange, yellow, and white) denote an input in the 2.5 to 5V range. You can create different palettes by changing the primary-color proportions stored in the RGB encoding table.