Trouble with a common anode rgb led

My issue is that I am unable to wire a common anode rgb led. I have been able to successfully wire a common cathode rgb led (i was even able to write code to make it fade through the rainbow). I have a link to a YouTube video that shows my problem. Https://youtu.be/wsqBnZ7iNa8

I failed to mention in the video that I was able to get each color to light up on the led, so I know it's not a faulty led. I also used quite a few leds so it's probably not a problem with the led.

If I understand how a cathode rgb led works, what am i missing to make to make an anode rgb led to work?

This is the code I used when testing in the video

int blue = 3; int green = 6; int red = 5; void setup() { // put your setup code here, to run once: pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT);

}

void loop() {

analogWrite (red, 200); // analogWrite (green, 200);

analogWrite (green, 1); //analogWrite (blue, 0); }

Do you understand the difference between common cathode and common anode ?

Please read this:- How to use this forum Because your post is breaking the rules about posting code.

How have you wired it up? The anode should be connected to 5V and each cathode to a resistor and the resistor to the Arduino output. Then an analogue write of 0 will turn it on fully and one of 255 will turn it off, the inverse of normal. If you want the normal numbers simply use 255 - value to invert the number.

I can't watch your video 'cause I'm at work...

What happens when you run your code?

What happens when you run the Blink Example (modified to address one of the pins your LED is connected to)?

i was even able to write code to make it fade through the rainbow).

If your LED is wired correctly, that should still work, but with a different ('inverted') color/brightness sequence.

Did you actually write the fade code, or did you copy it? The code you posted is static... It doesn't change colors or blink, and there no delays, etc., and if you wrote a 3-color fade program, I'm guessing you'd have written a better diagnostic program. ;)

P.S. Just as an example of what I'd do for a test/diagnostic program - Turn the LEDs (colors) on one-at-time for one second in a known-sequence... Red... Blue... Green... Then turn them all off (or all on) for a few seconds before starting the loop again.

And, you might want to throw-in a Pin-13 LED blink, just so you know the program is running even if the RGB LED doesn't light-up.

I've made some lighting effects and there's always a test-sequence that runs at power-on to make sure all the lights are working before the sound-activation kicks-in.

If you use the LED colors one after the other, i.e. not powering two or three colors at the same time, you can connect the cathodes directly to Arduino pins and have only one common resistor at the anode pin of the LED and the resistor connected to +5V.

The value of the resistor should be calculated such that the maximum current for the red LED (normally VF = 1,6V) is not exceeded. E.g.: (5V-1,6V) / 15mA = ca. 220 Ohm. For the blue LED this results in: (5V-3V) / 220 Ohm = ca. 9mA.

Just examples; calculation should be repeated on values of the datasheet for the RGB LED.

If you use the LED colors one after the other, i.e. not powering two or three colors at the same time, you can connect the cathodes directly to Arduino pins and have only one common resistor at the anode pin of the LED and the resistor connected to +5V.

So you cripple the usefulness of the LED for the sake of two 1 cent resistors.

I wouldn't say cripple, I would say: save space and money (I admit - not that much in this case, but: it works in all my projects and my attitude is always: make it as simple and cost effective as possible...);

Einstein said: "Everything should be made as simple as possible, but not simpler."

Not being able to run all 3 junctions together limits the brightness of the RGB led. The unimpeded current supplied to the anode is more than enough to feed the 3 current-limited cathodes.

rpt007: Einstein said: "Everything should be made as simple as possible, but not simpler."

And your suggestion takes you to a place that Einstein would have disapproved of. In short shit advice, that does not go down well here.

..well, forget it;

just recently I had the situatio where I could make use of my simplified solution. It always matters what environment or given situation you are ;-)

In a price competitive industrial environment very single penny counts and that is where my experience comes from.

Hi,
I think this will help the OP.
Com Anode_Cathode.jpg

Hope it helps… Tom… :slight_smile:

In a price competitive industrial environment very single penny counts and that is where my experience comes from.

Yes that is where mine comes from as well, selling a million units of things, and in those places a resistor costs $0.0001

Hi,

In a price competitive industrial environment very single penny counts and that is where my experience comes from.

hmm.. cost over reliability in an industrial situation. hope you have your liability insurance up to date.. Not sure what part of the world rpt007 comes from, but here in Australia OH&S is very big.

In this case three resistors, rather than one, add to the versatility of the LEDs function and provide convenient test points.

Tom... :)

And your green and blue levels will suffer with a resistor matched to red.

But if you don’t care and you’re willing to work around it then that’s 2 less parts to place.

What that’s got to do with a hobbyist checking out what can be done, it does explore cheap.

I appreciate all the help. I bought a few frosted rgb led's and a few clear, both from the same company. The frosted rgb leds gave me consistent problems. I used the clear anode rgb led and was able to get it to work. Im just confused why one type of anode rgb works, and another from the same company doesn't, but either way I think I got it to work. Thank you very much everyone.

Im just confused why one type of anode rgb works, and another from the same company doesn't,

The answer that springs to mid is that the company is selling sub standard parts. Is in in the far East? You often get factory rejects from there, instead of proper quality. Is it a company who knows what it is selling or is just selling what it can?