Pages: [1]   Go Down
Author Topic: RGB LED Common Cathode versus Common Anode  (Read 31698 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am playing with the make arduino starter kit I got in the last week like crazy. I got so antsy to want to control more than one RGB LED, that I went to radio shack and saw they had a "full color" led. I thought, yay, this looks exactly like the common cathode RGB LED that came in my kit, I'll take 3...

Long story short, the wiring for the 2 do not seem to work the same, and all of the info I am finding points to using PWM pins for common anode rgb LED's. I am planning on maxing out my arduino and using both digital and PWM pins. I already have the DIGITAL only pins working with the common cathode RGB LED.

So what is the difference? Do I need to apply voltage to the "ground" pin on the common anode RGB LED? Again I am using the DIGITAL only pins specifically 7, 4, and 2, or 13, 12 and 8.

This is the spec sheet for the common anode RGB LED:
http://www.radioshack.com/graphics/uc/rsk/Support/ProductManuals/2760028_DS_EN.pdf

Be nice, I'm a noob, and far from an electrical engineer, but I've gotten this to work up to this point. May need to take these RGB LED's back if they are too much of a hassle... bummer! :\
« Last Edit: October 20, 2010, 04:11:04 am by beeker » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With a common anode you connect the anode to the +5v and each individual LED to a resistor each. Connect that resistor to an output pin. Then a write LOW to that pin will turn the LED on and a HIGH will turn it off. This is called current sinking.

With a common cathode you connect the cathode to ground and connect each LED's anode through a resistor to the output pin.
Then a HIGH turns it on.
This is called current sourcing.
« Last Edit: October 20, 2010, 04:16:22 am by Grumpy_Mike » Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is called current sinking. What you have been doing so far is current sourcing.

Is there an advantage to use one or the other in respect to the way Arduino ports works and not considering it a problem whether one uses HIGH or LOW to turn things on?

I've always wondered about that one and never got a good explanation.

Korman
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there an advantage to use one or the other in respect to the way Arduino ports works

For the arduino with it's symmetrical ability to source and sink exactly the same amount of current then there is no preferred way.
Traditionally logic chips have been able to sink more than they can source so that is the way people think is "natural", to a beginner however it is confusing. This applies to outputs not inputs.

On a slight tangent there is is an overall current limit of 200mA on the power pins of an arduino. Now by mixing sourcing and sinking you can drive more load directly because sourcing only contributes to the +ve connection's current, where as sinking only contributes to the ground's connection's current.
« Last Edit: October 20, 2010, 05:01:16 am by Grumpy_Mike » Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

that's what I wanted to know.

Korman
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks grumpy mike, I got it to work. I did notice that on setup I needed to "current sink" all three pins for it to go off, before I wanted to turn the led's on at my programmed times.

Just curious combining digital, pwm, and another common cathode rgb led, will I be nearing the current limit, since I'll technically be powering 9 LED's in this manner, and 3 in the other method. I'll be maxing out my arduino output pins, so is that 200ma per led?
I have a 12v power supply, but I was hoping to be able to use a 9v on this project. I also have a car jump start battery that has 12v and 5v so that might be what I use too.

Thanks again, so far your advice on all topics I have posted on has been very helpful!
Logged

Seattle, WA
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I recently purchased one of the CA RGB LEDs from Adafruit, and was trying to see if anyone has example code I could look at. I'm thinking about diving in and just trying it out, but if anyone has some helpful tips I'd appreciate it.
Logged

Seattle, WA
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well that didn't take long. Here is a simple blink sketch I made... for reference.
Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(10, OUTPUT); // green
  pinMode(9, OUTPUT);  // Blue
  pinMode(8, OUTPUT);  // red
}

void loop() {
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(10, LOW);  // green
  delay(200);            
  digitalWrite(10, HIGH);
  digitalWrite(9, LOW);   // blue
  delay(200);
  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);   // red
  delay(200);
  digitalWrite(10, LOW);  // yellow
  delay(200);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);   // Cyan (Light Blue)
  delay(200);
  digitalWrite(10, HIGH);
  digitalWrite(8, LOW);   // Magenta (purple)
  delay(200);
  digitalWrite(10, LOW);  // White
  delay(200);
}

Update: I figured out how to mix colors, however I still have a question. How does one change the intensity of color in order to create a better mixture?
« Last Edit: January 16, 2011, 02:41:30 am by seattleandrew » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How does one change the intensity of color in order to create a better mixture?
With hardware. You need to change the resistor(s) in series with each LED to achieve a really smooth mix of colors. It can not be done entirely in software.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How does one change the intensity of color in order to create a better mixture
You could use the PWM pins and analogWrite.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You could use the PWM pins and analogWrite.
I need to read more closely. I thought OP was doing that.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're correct about the OP,but I was answering SeattleAndrew's question.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Seattle, WA
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow. smiley Thanks guys. Now would it be easier to create a mixture of colors with a Common Cathode RGB LED? I'm thinking about experimenting with both.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now would it be easier to create a mixture of colors with a Common Cathode RGB LED?
There is no difference between the two, it's just as easy with both types of LED, it only changes how you wire it up.
Logged

Pages: [1]   Go Up
Jump to: