|
Re: Programming RGB lighting
Not getting into the specifics of your situation, but in general:
An RGB LED can display most any color by varying the amount of Red, Green and Blue light emitted. For example, if you show 100% red and 100% blue, you get purple.
A 4-pin RGB LED - a raw LED, not one with a controller - has one pin for red, green and blue, plus one common pin. This common pin can be anode or cathode, depends on the device.
ALL LEDs require a dropping resistor, even if the supply voltage is lower than the lED voltage. Google "thermal runaway of LEDs" to see why. You might need to put a resistor in each color's control line, or maybe one in line with the common.
To make a color - white, let's say (which is R, G and B in a certain percentage of each, not 100% each) you control the three control pins with a duty-cycle of between 0% and 100% -- for white you use R=0.3, G = 0.59, and B = 0.11 (relative to absolute brightness - YMMV)
So turn on the Red pins with a 30% duty cycle, green with a 59% duty cycle, and blue with an 11% duty cycle. To change the color, change the duty cycles.
If your Digital Output pins don't "so" duty cycle, you can "bit bang" one anyway. See how fast it can deliver a signal of 10101010, and then change that signal as necessary (e.g, 25% is something like 11000000, 50% could be 11001100 or 11110000)
Hope this helps understand the "why"
__________________
I am N2IRZ - What's your callsign?
|