RGB LED QUESTION?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
1885
 
Posts: 94
Joined: Sun May 24, 2009 2:12 am

RGB LED QUESTION?

Post by 1885 »

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

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);  
}

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB LED QUESTION?

Post by adafruit_support_bill »

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

Re: RGB LED QUESTION?

Post by 1885 »

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.

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

Re: RGB LED QUESTION?

Post by Syn7 »

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...

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB LED QUESTION?

Post by adafruit_support_bill »

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.

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

Re: RGB LED QUESTION?

Post by Syn7 »

Thank you. Can't wait to dive in.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”