0

how to change color of a tri led (common anode)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

how to change color of a tri led (common anode)

by fatal510 on Mon Apr 21, 2008 11:09 pm

i got this tri LED from radioshack but its a Common Anode led (1 power 3 grounds)

datasheet for it is
http://rsk.imageg.net/graphics/uc/rsk/Support/ProductManuals/2760028_DS_EN.pdf

if u put the power to the power pin and then a put a ground touch a ground to each one it shows red, green and blue but when they are all hooked up you only see red and no matter what u change or send to it. it will dim the red one or make red brighter it seems

but if i put power to it and then green and blue to the ground it will make cyan. but once that red one is hooked up its just pure red from then on
fatal510
 
Posts: 3
Joined: Mon Apr 21, 2008 11:03 pm

by franklin97355 on Mon Apr 21, 2008 11:13 pm

You need to adjust the resistance to each leg to balance the efficiency of the three leds. Or you could drive them with different amounts of PWM to make the colors change.

franklin97355
 
Posts: 21488
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

by fatal510 on Mon Apr 21, 2008 11:59 pm

i don't get how i'm spouse to set values to each color when there seems to be only 1 "input" the 1 power pin(anode) the rest are 3 cathodes the negatives
fatal510
 
Posts: 3
Joined: Mon Apr 21, 2008 11:03 pm

by adafruit on Tue Apr 22, 2008 12:02 am

the cathodes are also 'inputs', they're just -negative- ones! (a pull instead of a push)

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by fatal510 on Tue Apr 22, 2008 12:05 am

can anyone direct me to a tutorial on something that would help me get this working. im not sure i get this pull/push stuff
fatal510
 
Posts: 3
Joined: Mon Apr 21, 2008 11:03 pm

by mtbf0 on Tue Apr 22, 2008 12:24 am

sounds like you're hooked up with a single resistor between the common and 5v or whatever. try resistors on each of the cathodes chosen for the voltage drop across each color with the anode connected directly to 5v.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by Silver on Wed Apr 23, 2008 3:29 am

Fatal510, thank you for posting the spec sheet for this LED. I stopped by Radio Shack on the way home and picked one up.

Because this is a common anode LED, you need to supply 5v to the anode, and connect the three cathodes to three current limiting resistors and then to three PWM output pins.

This is a very bright LED. Don't watch it TOO long. I still have a bright spot in the middle of my vision as I am typing this. :shock:

Code: Select all | TOGGLE FULL SIZE
/* Tri-color Common Anode LED with subroutine
/  Wiring Diagram for common anode LED from Radio Shack
/
/             +--|>|--- 68 ohm ---  PWM pin 9   (Red)
/   +5V  -----+--|>|--- 56 ohm ---  PWM pin 10  (Green)
/             +--|>|--- 56 ohm ---  PWM pin 11  (Blue)
/
/  Spec sheet provided voltage and current requirements
/  < http://rsk.imageg.net/graphics/uc/rsk/Support/ProductManuals/2760028_DS_EN.pdf >
/  Resistor values calculated by < http://led.linear1.org/1led.wiz >  (one led dot wiz)
/
/  PWM pins will supply GROUND to pins, therefore 255 (5V) = off, 0 (Ground) = full on
*/

int level;                                 //value to send

int ledpinR = 9;                           // Red channel
int ledpinG = 10;                          // Green channel
int ledpinB = 11;                          // Blue channel

void setup()
{
  Serial.begin(9600);                      // set up Serial library at 9600 bps

  analogWrite(ledpinR, 225);               // sets initial values
  analogWrite(ledpinG, 255);
  analogWrite(ledpinB, 255);
}

void loop()
{
  countDown(ledpinR);
  countDown(ledpinG);
  countUp(ledpinR);
  countDown(ledpinB);
  countUp(ledpinG);
  countDown(ledpinR);
  countDown(ledpinG);
 
  delay(1000);
 
  for(level = 0; level <= 255; level++)    //Fade all channels back to off
  {
    analogWrite(ledpinR, level);
    analogWrite(ledpinG, level);
    analogWrite(ledpinB, level);
    delay(5);
  }

}  //end of loop()

void countUp(int pin)
{
  for(int level = 0; level <= 255; level++)
  {
    analogWrite(pin, level);               // sets the value (range from 0 to 255)
    delay(5);                              // waits for 5 milliseconds to see the dimming effect
  }
}   //end of countUp

void countDown(int pin)
{
  for(int level = 255; level >= 0; level--)
  {
    analogWrite(pin, level);               // sets the value (range from 255 to 0)
    delay(5);                              // waits for 5 milliseconds to see the dimming effect
  }
}   //end of countDown



Hope this helps.

Silver
Silver
 
Posts: 12
Joined: Mon Apr 21, 2008 1:39 am

Please be positive and constructive with your questions and comments.