Author Options:

RGB Led doesn't mix colors Answered

Hey all I am working with common anode RGB LED. I hooked each leg (red, green, blue) to pins 2-4 of my Arduino UNO. I then hooked the anode to 5v via a 22 ohm resistor. The code I wrote was very simple; turn pins 2 through 4 low, delay 500, turn pins 2-4 high. The problem I found was that instead of the color turning white it stayed red. I tried mixing red with green and red with blue, each time same thing it stayed red. Does this sound right?




25 days ago

It is logical.
See, every color of the LED has another forward-voltage and thus needs another resistor.
Also, every color has another lm/mA (Brightness per current).
As red normally has a very low Uf, almost all current goes thru the red and almost nothing (if even) thru the other 2.

First, you need the same brightness-level. Check your datasheet for the current needed for that for each color.
Second, check what voltage is needed for that current for each LED. Can be done in the datasheet or by carefully measurement with a lab powersupply.
Third, Calculate the resistor for (and thats VERY important!!) FOR EACH LED. You cannot use one resistor on common anode! Rg=(5V-Ufg)/Ig where g means green as an example.

Hook up the 5V to the common anode. from each cathode, go thru the respective resistor to GND.


Reply 25 days ago

Thank you very much for that explanation it was EXTREMELY helpful! With that said (and with out you having access to the data sheet) what are your thoughts on using my the circuit I outline in my original post as is? I ask because what started me down this worm hole is I am trying to figure out how to use transistors with an RGB led so I don't have color mix. With it not mixing color right now I am wondering if I just leave it that way. Thank you againfor your help!


Reply 24 days ago

I am unsure if i understand you correctly... You want to use a RGB LED but NOT mix the colors?
You want to switch on and off the LED(s) with a/3 transistor? See attachment for that.
For yommon anode as you have and BJT as you asked, check https://i.stack.imgur.com/IxF5v.gif

RGB Common Cathode driver.jpg

26 days ago

Each color usually needs their own resistor, at least in most cases.
Then there is the problem of using the right pins on the LED.
If the LED indeed only requires a single resistor on the negative pin then it still leaves the question if you used the right pins.