RGB LED QUESTION?
Moderators: adafruit_support_bill, adafruit

RGB LED QUESTION?

by cwc1885 on Mon Dec 31, 2012 8:41 pm

I set up an RGB LED per the Adafruit tutorial. It was the RGB led from the adafruit kit.
http://learn.adafruit.com/adafruit-ardu ... ino-sketch
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: 59
Joined: Sun May 24, 2009 2:12 am

Re: RGB LED QUESTION?

by adafruit_support_bill on Tue Jan 01, 2013 7:53 am

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.
User avatar
adafruit_support_bill
 
Posts: 31719
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB LED QUESTION?

by cwc1885 on Tue Jan 01, 2013 1:47 pm

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: 59
Joined: Sun May 24, 2009 2:12 am

Re: RGB LED QUESTION?

by Syn7 on Thu Jan 03, 2013 5:40 am

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?

by adafruit_support_bill on Thu Jan 03, 2013 8:12 am

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.
User avatar
adafruit_support_bill
 
Posts: 31719
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB LED QUESTION?

by Syn7 on Fri Jan 04, 2013 5:46 am

Thank you. Can't wait to dive in.
Syn7
 
Posts: 152
Joined: Sat Nov 17, 2012 3:06 am