Folks - before you heave a big sigh and think "No, surely he's not asking that again?", I hope I'll surprise you.
I know that I can't have 2+ LEDs sharing the same current limiting resistor when connected to the same power supply.
I know that I need to have one resistor per LED when using the same power supply.
However, can I use a single resistor as shown in situation C if the +ve for each comes from separate GPIO pins?
There - with any luck you've sucked in that sigh now.
I have a suspicion that it should be OK as they're diodes, but if someone can give me a definitive answer before I destroy something that'd be smashing.
It's OK if there's only one LED on at a time. Otherwise the current will divide, possibly unevenly (just like 'A'). And if you turn-on only one LED it will be brighter with all of the current going through one LED.
...Sometimes you can get-away with stuff you shouldn't do. ...Nothing is going to blow up as long as the resistor is high enough in value to safely limit the current.
Circuit A: Current will only split 50/50 if LEDs are exactly the same, which they probably are not.
Not a big problem if you use a CL resistor calculated for max current of a single LED.
Circuit B: Must be used if LEDs are very different, e.g a red LED with a Vf of 1.8volt and a blue LED with a Vf of 3.3volt.
If you use a red and a blue LED in circuit A, then only the red LED will be lit.
Circuit C: A variation of circuit A, but with an added series resistance of ~25ohm to each LED (internal pin resistance). Currents are divided more equally because of that, but LED Vf must about the same.
Downside is that total current is fixed. More LEDs 'on' means brightness per LED drops.
Leo..
However, can I use a single resistor as shown in situation C if the +ve for each comes from separate GPIO pins?
No. Ckt C has similar issues as ckt A.
To help you understand, lets assume: (mostly made up numbers for illustration, but not too far off the mark for a typical led).
Each LED needs 5 milliamps (0.005 amps)
The voltage across the LED for 5 milliamps is 2 volts.
And you are powering the circuit with 5 volts.
In Ckt B, the left connection is 5V and the right connection is ground.
Because we said the voltage across this LED is 2 volts then the voltage across the resistor is 5 - 2 = 3V
The resistor value must then be R = V / I --> R = 3 / 0.005 = 600 Ohms.
In Ckt C Lets assume only one output is on ON (i.e. 5V, we will assume the digital output is 5V even though in actuality it will be somewhat lower).
The resistor being 600 ohms (from the Ckt B calculation). Now all works as in Ckt B.
Now we will turn the 2nd output ON Now the current needed is 10 milliamps (0.010 amps). The resistor is still 600 ohms, but the drop across the resistor is not V = I * R = 0.010 * 600 = 6 volts!!!
But we can't have 6 Volts because the circuit only has 5V.......hmm.
The result is the LED may or may not light up. But if they do, they will be very dim.
I suggest you take a few minutes and read about:
Ohms law
Kirchhoff's voltage law
Norton's current law
The names may sound intimidating however they are really simple concepts. However they are the basis for all circuits such as these and you would do well to understand them.
It seems that it boils down to... "the blue smoke stays inside the components but the brightness will drop".
As this is part of an Alexa controlled lamp I'm creating with an ESP8266 using three RGB LEDs, and I want the brightness as HUGE as possible (and that the Vf of the R and G and B will differ) I should take the massive financial hit and use separate limiting resistors rather than being a darned cheapskate and trying to get away with just the one.
Sincere thanks for your responses.
That Ohm's law one - I shall hide back under a box somewhere and be quiet.
It seems that it boils down to... "the blue smoke stays inside the components but the brightness will drop".
Based on your statement you have a good handle on the concept. As for the Ohm's law thing, if you continue down this path (controlling stuff etc) you will eventually learn it. I will admit though it is much easier if someone could explain it rather than studying some web site.
markakite:
That Ohm's law one - I shall hide back under a box somewhere and be quiet.
don't - it really is very important to know this - it is the most basic knowledge that you need when dealing with electronic circuits (or even electricity in general).
take the time to calculate various examples of circuits, mainly in series and in parallel.
Ohm's Law is basically V = I. R
it might help by drawing your circuits in a complete loop; starting simple with a battery, or more ideally with a power rail - as in the picture below on the right.
that then helps in figuring out what is going on in C)
(also in B)
I've done the Ohms Law and associated stuff. I just wasn't sure what would happen with the single resistor and two(+) GPIO pins, and yes, it was easier to ask than to try to get this old brain to work it out, and I really appreciate the time you kind folks have spent explaining it.
It's not because I'm a cheapskate, as I suggested; I was hoping to save a bit of space. Time to order some SMD resistors and try not to lose them.
There's also another approach - ditch the normal LEDs and use a WS2812 or similar. Those need 1 external cap per RGB Led, but that's less external parts than 3 per RGB led.
Another reason to go that route is that the pin drivers on the ESP8266 are rather weak, so you may not be able to get it as bright as you want (esp since it's a 3.3v device) without external transistor to switch the LED.