Rainbow LED indicates voltage with color

Microchip PIC12F675

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 PIC12F675 microcontroller driving IC2, an 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, available in the Downloads section, contains a program for a PIC microcontroller in MicroEngineering Labs' PicBasic Pro language, the compiler for which can be downloaded from the link (Ref. 1) at the end of the article.This program converts a 0 to 5 V 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.

Using a minimal number of components, this voltage-to-color converter uses a single rainbow LED to monitor an analog voltage level.
Figure 1. Using a minimal number of components, this voltage-to-color converter uses a single rainbow LED to monitor
an analog voltage level.

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.5 V, which switches all LEDs off. “Cool” colors (shades of blue, purple, and aqua) denote an input in the 0 to 2.5 V range, and “hot” colors (shades of red, orange, yellow, and white) denote an input in the 2.5 to 5 V range. You can create different palettes by changing the primary-color proportions stored in the RGB encoding table.

You can alter the color versus input-voltage palette by modifying the firmware.
Figure 2. You can alter the color versus input-voltage palette by modifying the firmware.

Reference

  1. PicBasic Pro compiler

Downloads

  1. PIC program for the PicBasic Pro compiler

Materials on the topic

  1. Datasheet Microchip PIC12F675
  2. Datasheet Kingbright AAF5060PBESEEVG

EDN