I'm trying to make an RGB LED that came with my Lilypad Protosnap cycle through the three basic colors: red, green, and blue.
The issue is that even if I have set only the red to light up, all three light up and I get a white light. Same for lighting green -- or lighting blue. All three light up.
One fundamental question I have is -- I read a post that to light an R, G, or B LED pin, you need to use LOW for on, and HIGH for off-- the opposite of a plain ol' LED. Is this true?
This is the method I'm using and it is being lit -- all of them -- but I can't get each LED color to light up individually.
I've searched for similar questions thinking that others must have run into this issue, but I can't find anything that matches.
Not sure if this helps out of context -- but here are relevant pieces of my code -- I can't figure out what I'm missing!
Establishing each color's pin:
const int ledPinR = 9;
const int ledPinB = 10;
const int ledPinG = 11;
Setting each pin as output:
void setup()
{
pinMode(ledPinR, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinG, OUTPUT);
}
Cycling through the colors:
void loop()
{ digitalWrite(ledPinR, LOW);
digitalWrite(ledPinR, HIGH);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinB, HIGH);
digitalWrite(ledPinG, LOW);
digitalWrite(ledPinG, HIGH);
}
Any words of wisdom? Thank you in advance!