Datasheet
NOT WORKING? (3 things to try)
MAKING IT BETTER
CODE (no need to type everything in just click)
MORE, MORE, MORE:
31
CIRC-12
Download the Code from (http://ardx.org/CODE12A)
(copy the text and paste it into an empty Arduino Sketch)
More details, where to buy more parts, where to ask more questions:
Seeing Red
The red diode within the RGB
LED may be a bit brighter
than the other two. To make
your colors more balanced,
try using a higher ohm
resistor (or two resistors in
series).
Looking For More?
(shameless plug)
If you’re looking to do more
why not check out all the
lovely extra bits and bobs
available from
http://www.Adafruit.com
LED Remains Dark or
Shows Incorrect Color
With the four pins of the LED
so close together, it’s
sometimes easy to misplace
one. Try double checking each
pin is where it should be.
More Colors Analog Color Control
I imagine you are less than impressed by the While switching between colors is good fun RGB LEDs
cyan glowing LED before you. To display a really come into their own when mixed with analog
different color change the color in the code to control. Using PWM (pulse width modulation) it’s
one of the others. possible to produce nearly any color and fade
setColor(ledDigitalOne, CYAN); ---->
between them. Sadly the code for this is a bit too long
setColor(ledDigitalOne, **NEW COLOR**);
for the section above, for an example program (with
Display a Random Color
lots of comments).
Of course we can do more than display a
constant color, to see how we cycle through
Download the code from:
http://ardx.org/MABE12A
random colors change the loop() code to.
void loop(){
//setColor(ledDigitalOne, CYAN);
randomColor()
}
//RGB LED pins void setup(){
int ledDigitalOne[] = {9, 10, 11}; for(int i = 0; i < 3; i++){
//the three digital pins of the digital LED pinMode(ledDigitalOne[i], OUTPUT);
//9 = redPin, 10 = greenPin, 11 = bluePin //Set the three LED pins as outputs
}
const boolean ON = LOW; }
//Define on as LOW (this is because we use
//a common Anode RGB LED (common pin is void loop(){
//connected to +5 volts) setColor(ledDigitalOne, CYAN);
const boolean OFF = HIGH; //Set the color of the LED
//Define off as HIGH
//randomColor()
//Predefined Colors
const boolean RED[] = {ON, OFF, OFF}; }
const boolean GREEN[] = {OFF, ON, OFF};
const boolean BLUE[] = {OFF, OFF, ON}; void randomColor(){
const boolean YELLOW[] = {ON, ON, OFF}; int rand = random(0, sizeof(COLORS) / 2);
const boolean CYAN[] = {OFF, ON, ON}; //get a random number within the range of
const boolean MAGENTA[] = {ON, OFF, ON}; //colors
const boolean WHITE[] = {ON, ON, ON}; setColor(ledDigitalOne, COLORS[rand]);
const boolean BLACK[] = {OFF, OFF, OFF}; //Set the color of led one to a random color
delay(1000);
//An Array that stores the predefined colors }
const boolean* COLORS[] =
void setColor(int* led, boolean* color){
{RED, GREEN, BLUE,YELLOW, CYAN, MAGENTA,
for(int i = 0; i < 3; i++){
WHITE, BLACK};
digitalWrite(led[i], color[i]);
}
}
http://adafruit.com