Lilypad RGB LED - R, G, and B always lit

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!

jhaaaa: 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?

That's not the opposite of a plain led. Sometimes you do plain leds that way. it just depends on whether you have the led between the pin and ground or between the pin and 5V.

For an RGB led, you have one common pin and three individual color pins. If it is common anode then you do it one way and for common cathode you do it the other. You have to know which type of RGB led you have and whether the common pin goes to ground and HIGH turns it on or whether the common pin goes to 5V and LOW turns it on.

The problem with your code is that it is running through turning each pin on and off at a super high speed. It is cycling through all of that in less than a millisecond. So your eyes just see white. Your eyes aren't fast enough to see the individual colors coming on and off. Put a little delay between the digitalWrite calls and see if it doesn't look different.

Looking at the eagle files for the Protosnap, the RGB uses a common Vcc (3.3V) therefore to turn on a given LED you will have to pull down the "control" pin to give you the potential difference. This the pin will be active LOW.

To prevent the LED's from turning on when not wanted you should have an initial condition where they are HIGH (i.e. all off).

Delta_G is correct, you need a delay between each digital write code.

Try a 1 second delay first then tweak till you have a speed you like.

void loop()

{ digitalWrite(ledPinR, LOW); delay(1000); digitalWrite(ledPinR, HIGH); delay(1000); digitalWrite(ledPinB, LOW); delay(1000); digitalWrite(ledPinB, HIGH); delay(1000); digitalWrite(ledPinG, LOW); delay(1000); digitalWrite(ledPinG, HIGH);


Thank you so much for your guidance here! The feedback was VERY helpful in moving my project along. Sorry it took so long to post my reply and thanks here -- I was grappling with the project in a very real way for way too long. :stuck_out_tongue_closed_eyes:

But I wanted to be sure to share the outcome here just to share the learning path I took -- and to possibly learn even more!

I wrote this up to describe the journey and solution: It includes the patterns, circuit diagram, and code, if anyone is interested.

Take good care - and hopefully as I continue to learn and build, I'll be able to contribute back to this community. Thank you again!