Current limiting a RGB-LED

Hi guys!

I'm trying to power a RGB-LED from an Arduino Pro Mini (3v3, 8MHz variant) and have got confused over how to connect them up. The reason for my confusion is that 2 of the 3 "colors" have got an forward voltage of 3.2V while the 3rd's is at 2.0V. What confuses me furthermore is that the LED is a common anode-type of RGB-LED so I don't know where and what value of a resistor I should put in series with it. Should I use 2 separate resistors - one for the two colors with the If = 3.2V and one for the single color with the If = 2.0V? But then again the 2 similar colors will draw a total of 0.020+0.020 milliamps through their shared resistor when both are lighted at the same time, right?

Note that I'm going to GND them to 3 digital pins on the Arduino so I can regulate their individual intensity with PWM and power them from the Arduino's Vcc pin (because that's possible, right?).

Thanks in advance!

Use a separate series resistor for each cathode lead. Should work fine, as long as you don't exceed the max amperage capacity of the Vcc pin.

You can start with resistance values determined by the usual formula, but you might find that you need to tweak the values a bit. One hopes that the individual LEDs in the case are well matched for intensity, but hey, it's not a perfect world.

Maybe it'll seem "too many" parts, but with the following circuit you can operate the LEDs over a "wide" range of Vcc. The currents will remain constant vs. ?Vcc. When on, each would draw 10mA.

It is based on the current regulator below --

Runaway Pancake's circuit is the right one... but, it is worth repeating what justjed said. (assume I repeated it) The reason you want individual resistors for each led is about brightness and safe current limiting. These values will need to be tweaked to YOUR satisfaction so you get the correct/equalized brightness after you figure out the nominal values from OHMS law related to nominal current & voltage (adjusted for foward voltage drop).

In my experience, withe the batch of LEDs I ordered, I had to tone down the brightness (increase resistance) of RED (reduced current) to match the brightness seen with maximum safe current applied to the BLUE LED.

You are aware of course that the Zener diode in that circuit plays a vital roll in making it a constant current regulator… Without it, if you change the voltage across the load, the current will change as the base voltage is allowed to vary (thanks to that 1k resistor). The zener diode acts to keep the base voltage constant (as long as the voltage of the logic input is higher than the breakdown voltage of the zener).
For that circuit to work with a 3.3V arduino, you would need to add a zener diode with Vz <= 3V.

I'm trying to power a RGB-LED from an Arduino Pro Mini (3v3, 8MHz variant)...

... 2 of the 3 "colors" have got an forward voltage of 3.2V

If you run a 3.2V LED directly from a 3.3V source, you are going to have problems... :(

The current (brightness) is controlled by the voltage dropped across the resistor. With ~3.2V across the LED that only leaves ~0.1V across the resistor. That's not much "wiggle room" and it's going to be difficult to predict the current. It's a kind of "leverage" where a slight variation in supply voltage or LED forward voltage can cause huge variation in brightness. It also assumes you get the full 3.3V across the LED & resistor, with no drop through the Arduino.... But in fact, you will get a drop across the Arduino and the 3.2V LED might not light-up at all!

It would be best if you use at least 5V for the LEDs, with a transistor or FET driving each LED.

If you replace the Zener with a TIL431 and a 10K pot wiper to adj cw to cathode and ccw to anode you would have a variable current generator. and an NPN Darilinton would give some real current although it might require more than 10-12 Volts to insure compliance over the full range and remember the small one, 2N3904? is only good for a hundred mA or 325mW dissipation. bforeee the magic smoke gets away...

Doc

The zener is used in the latter example, but it would serve no purpose in the RGB circuit I drew.
As sources of VB, Arduino (digital) outputs are stable, predictable voltages - “zener-like” in that respect.
OK ?

[cleaned up formatting sub,/sub]

[quote author=Runaway Pancake link=topic=120206.msg906464#msg906464 date=1346153889]

The zener is used in the latter example, but it would serve no purpose in the RGB circuit I drew.
As sources of VB[/b], Arduino (digital) outputs are stable, predictable voltages - “zener-like” in that respect.
OK ?
[/quote]
They aren’t because of the 1k resistor. The voltage drop across this resistor will vary depending on base current, which means the voltage at the base wont be a fixed reference. In order for it to be a constant current source, the voltage at the base with respect to ground (in this case) needs to be a fixed constant.
Thinking about it, in your circuit, thanks to the 220 ohm resistor, if you remove th 1k resistor, and just connect the arduino pin to the base, you would have a constant current source as the base voltage would always be +5v.
Almost no current would be drawn from the arduino pin as long as the full amount of current could be drawn through the load. If you were to remove the load, or of for some reason not enough current could flow through the load, the remainder would be sourced from the arduino pin. As the current in this case is set to be 20mA, that wouldn’t be a problem - the arduino could handle it no problem.

You OK?

Here it is: There’s a 0/3V output into the base of that transistor.
The voltage across that 220? resistor is going to be VB - VBE:
nominally, 3V - 1V = 2V.
IE is 2V / 220? = 9mA
IC approx = IE