LilyPad RGB Tri-Color LED - Setup issue

Hi All,

I’m teaching myself the LilyPad Protosnap board, and the C language.

Following a C tutorial by Leah Buckley using a sampling of Sew Electric, I was able to setup a simple program to initialize any of the LEDS on the Protosnap and blink them. However, when it comes to the Tri-Color LED (pins 9, 10, 11 for Red, Blue and Green respectively), in the Setup section of my code, when I initialize all of the digital pins as outputs (9,10, and 11), each color stays lit and competes against the others. This does not happen if I initialize any of the white LEDS on the board (5,6,A2,A3,A4).

This further creates an issue when I try to blink each color individually because there’s always a color that stays lit.

My questions are:

A. Why does this happen differently with the tri-color LED versus the single color LED?

B. How can I blink each of the colors of the tri-color LED without any one of them staying lit?

Thanks in advance.

Cheers,

Richard

Hi Richard,

Initializing the pins as output should not turn them on. The digitalWrite / analogWrite command is what actually turns on the power. I have always found them to be set to off by default, but you could begin your program by doing a digitalWrite(9,LOW) command to turn pin 9 off explicitly. Then turn it on when you want.

If you are using an RGB LED, you will want to make sure that you are plugged into pins that support PWM so that you can use analogWrite. This will allow you to adjust the brightness of each color to mix them to the rgb value that you want. I don’t know off hand if 9, 10, 11 are PWM capable on the LilyPad, but PWM is usually indicated on the board with a ~ symbol.

So once each anode leg is plugged into a pwm capable pin, you can explicitly set them all to low and then use analogWrite() to set each pin to the desired brightness.

Trevor

Hi Trevor,

Thanks for your reply.

I did not know that about PWM, or how the values of RGB could be mixed as light to create specific RGB colors! This Lilypad tri-color LED does not have a “~” symbol or “pwm” printed on it.

Regarding the first issue, about how the LED stays on after it’s initialized, it’s still happening. It’s not critical as I am learning, and jumping around whenever I stumble, but I figured I’d share my code and a picture of my assembly to see if you have any further thoughts.

Thanks again.

Cheers,

RIchard

// declarations

int led = 11;

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin as an output.

pinMode(led, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(led, LOW);

}