Saturday, September 6, 2014

16M color using RGB led and arduino #15

RGB leds have 4 leads in it. RGB leds ase like common led but its just three led with RED GREEN and BLUE colored LED in single LED body . Each pin are for red , green and blue colored led and one for ground.
Using Arduino's PWM feature we can change the intensity of each of the individual led and the color of the led will give the 2^8 level ie 255 for each color. Then with three eight bit colored led it will give 2^24 level of color. I.E about 16 million of color.But our human eye couldn't detect all those colors.
Now connect the pins of RGB led to any of the PINS in arduino labeled with PWM or ~ kind of symbol.




Most of the RGB led have the above pin configuration. The cathode pin is ground connected to arduinol's ground and other to any of the PWM pins lets say 9 to R,10 to G and 11 to B.
In arduino's program add
#define R 9
#define G 10
#define B 11

In setup() add
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);

Now any where in program we can adjust the brightness of each of the led to change the color the led using analogWrite(X,VALUE);
where X is either R, G or B
and VALUE is anywhere between 0 to 255. Its always better to and some resistors 220 to 330 (around)  to the R G and B pins in series to arudino 's pin to limit the current flowing.



No comments:

Post a Comment