Full Color LED - Random Color Generator
Here is a simple program to randomly see all the color combination you can draw out of a FULL Color LED from Radio Shack.
The Full color 5mm LED from RadioShack (276-0028) has 4 leads: (from the flat side of the LED body) pin 1 Red (-) pin 2 Positive Voltage pin 3 Blue (-) pin 4 Green (-)
To trigger the desired color you set the pin to ground; so- if you want red, you would have voltage on pin 2 and pin 1 to ground... Blue would be the same except you ground pin 3 and so forth.
On it's own, the LED can only display one color at a time. When you use the PWM of analogWrite() from a Arduino you can watch all the color combinations that you can make with the LED.
Note about operation. PWM (Pulse Width Modulation) causes the LED to see a variance in voltage between 0 (0) and 5 (255) volts on a pin. When the LED sees 0 volts on a pin, that color will be the brightest. If the pin see 5 volts (255) the color will no show.
Hook up a 5 volt supply from the Arduino. Add a resistor to Pin 2 of the LED (220 Ohms)
Add three wires from PWM pins from the Arduino. I used 2,3,4 on my Mega (use whatever you want). Then use the code to randomly generate colors on the LED.
I included serial output so you can monitor the RGB numbers as the LED changes.