RGB LED QUESTION?

I set up an RGB LED per the Adafruit tutorial. It was the RGB led from the adafruit kit.
Why do I get RED with setColor(0, 255, 255); ?????
setColor(255, 255, 255); turns everything off?
Using 3 560 ohm resistors. Is it the resistors?

To get RED here is my code:

[Edit - moderator - please use the 'code' button when submitting code]

Code: Select all | TOGGLE FULL SIZE
`int redPin = 11; int greenPin = 10; int bluePin = 9; void setup() {   pinMode(redPin, OUTPUT);   pinMode(greenPin, OUTPUT);   pinMode(bluePin, OUTPUT);  } void loop() {   setColor(0, 255, 255);   delay(1000);     setColor(255, 255, 255);    delay(1000); } void setColor(int red, int green, int blue) {   analogWrite(redPin, red);   analogWrite(greenPin, green);   analogWrite(bluePin, blue);  }`

cwc1885

Posts: 71
Joined: Sun May 24, 2009 2:12 am

Re: RGB LED QUESTION?

The RGB LED is a "Common Anode" led. The anode for R, G & B is tied to +5v and the three cathodes are pulled low to turn them on. This means that all the logic is inverted.

With setColor(255, 255, 255), all three cathode resistors are at 5v, so there is no voltage across the LED. With setColor(0, 0, 0), the cathode resistors are at 0v, so there is a 5v drop and the led illuminates.

Posts: 40247
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB LED QUESTION?

adafruit_support wrote:The RGB LED is a "Common Anode" led. The anode for R, G & B is tied to +5v and the three cathodes are pulled low to turn them on. This means that all the logic is inverted.

With setColor(255, 255, 255), all three cathode resistors are at 5v, so there is no voltage across the LED. With setColor(0, 0, 0), the cathode resistors are at 0v, so there is a 5v drop and the led illuminates.

Excellent! After I posted this I wrote code and figured it out but I was not sure why it worked.
Thank you so much for the reply.

cwc1885

Posts: 71
Joined: Sun May 24, 2009 2:12 am

Re: RGB LED QUESTION?

by adafruit_support » 01 Jan 2013 11:53
With setColor(255, 255, 255), all three cathode resistors are at 5v, so there is no voltage across the LED. With setColor(0, 0, 0), the cathode resistors are at 0v, so there is a 5v drop and the led illuminates.

Haven't done the tutorial for RGB's yet. I ordered the Diffused RGB (tri-color) 10mm LED (10 pack) and a few Clear 'Piranha' Super-flux RGB (tri-color) LED's. Still waiting for them to get here in the mail. Should be in a few days now.

But I'm curious. So are the three 255's in the order R G B? and will having 0 0 0 make it look white then? 0 255 0 purple? etc etc...
Syn7

Posts: 152
Joined: Sat Nov 17, 2012 3:06 am

Re: RGB LED QUESTION?

So are the three 255's in the order R G B? and will having 0 0 0 make it look white then? 0 255 0 purple? etc etc...

Yes.