RGB LED QUESTION?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

RGB LED QUESTION?

Postby cwc1885 » Mon Dec 31, 2012 7: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
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: 38
Joined: Sun May 24, 2009 1:12 am

Re: RGB LED QUESTION?

Postby adafruit_support_bill » Tue Jan 01, 2013 6: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: 15962
Joined: Sat Feb 07, 2009 9:11 am

Re: RGB LED QUESTION?

Postby cwc1885 » Tue Jan 01, 2013 12: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: 38
Joined: Sun May 24, 2009 1:12 am

Re: RGB LED QUESTION?

Postby Syn7 » Thu Jan 03, 2013 4: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: 97
Joined: Sat Nov 17, 2012 2:06 am

Re: RGB LED QUESTION?

Postby adafruit_support_bill » Thu Jan 03, 2013 7: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: 15962
Joined: Sat Feb 07, 2009 9:11 am

Re: RGB LED QUESTION?

Postby Syn7 » Fri Jan 04, 2013 4:46 am

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


Return to General Project help

Who is online

Users browsing this forum: No registered users and 8 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]