Tri-color LED Controller with Serial Interface

(a.k.a. "Smart LED")

Updated 15-Aug-2005 by Phil Ray


SCHEMATIC

You are looking at a converted .gif file. Get the original PostScript file made with xcircuit.


DESCRIPTION

This device can independently control the brightness of the three sections (red, green, and blue) in a tri-color LED. Of course, individual LEDs could also be used.

I designed it as a diagnostic aid for use where only one microcontroller pin is available, but where on/off status of more than one process or relative comparison of two or three quantities was needed. Some possibilities include: combination pilot lamp/status indicator, internal temperature indicator, robot "mood" indicator, etc..

The RS-232 level converter was added to allow it to be used in systems that already have an RS-232 port (like an industrial PC). In the circuit, D1 and R1 protect the LED in optical coupler OC1 from excess reverse voltage and forward current, respectively. The configuration of the LED, phototransistor and R2 provide a logic "1" to the 2343's input pin when a "mark" (-9 to -12v) is present on the RS-232 line, and a "0" when a "space" (+9 to +12v) is present. The "INPUT SELECT" three pin header allows choosing between TTL/CMOS (pins 2,3 shorted) or RS-232 (pins 1,2 shorted) logic levels.

The unit accepts ASCII serial input at a fixed rate of 9600bps in the format "xxC", where "xx" is a brightness level from 00 to 31 (brightest) and "C" is the first letter of the desired color, any of [rRgGbB]. Thus, "15r" would set the red LED to half brightness and "31B20G" would set the blue LED to full brightness and the green LED to 20/31 brightness while not changing the level of the red LED. Brightness values greater than 31 are treated as full brightness (31). Carriage returns, line feeds, and other characters can be sent before and after the control string but are ignored. The unit makes the brightness change as soon as it receives the color letter in the string.


FILES

Source code (smart-led-1.0.asm) and Intel .hex file (smart-led-1.0.hex)

Source code (led-1.1.asm) and Intel .hex file (led-1.1.hex) for my original "test" program that presents a slowly and ever changing color pattern. Does not require serial input. Good for viewing all of the pretty colors an RGB LED can make!

macro.asm Additional macros needed by the source code

ledload.sh Bourne Again Shell script that demonstrates the use of the device as a "system load" indicator on a Linux-based PC.


PHOTO

An early prototype. Some of the component values are different than those shown on the schematic. The wiring is slightly different too. When building your own, refer to the schematic and _not_ this photo.

LATEST

Check this section for updates and new ideas.

Ideas I would like to develop:

  • Individually addressable SmartLEDs that can be controlled from a single data line
  • Data supplied over the Vcc wire, like Dallas 1-wire, so that only power and GND would need to be connected between multiple SmartLEDs.

    HOME