Go Down

Topic: What resistor for LEDs? Newbies guide (Read 1 time) previous topic - next topic

Boffin1

Oct 15, 2012, 05:17 pm Last Edit: Oct 16, 2012, 03:06 pm by Boffin1 Reason: 1
I am not trying to teach granny to suck eggs, I have just seen so many " what value resistor " postings, and might have missed some good explanations in all the search results ....

Newbies to the hardwired side of micros seem to get confused about connecting LEDs to the Arduino pins, heres a little simplified basic understanding.

If you look at a LEDs spec, it will state the Vf or forward voltage at a current that the LED is happy with without burning out.

The forward voltage is different for various colour LEDs ( to do with the chemicals used in construction )

Once you apply more than the Vf to the LED,   it will try and drag the supplied voltage down to its forward voltage ( like a zener diode ).

If you are trying to supply 5 volts to a 2 volt Vf  LED directly from the Arduino pin, the LED will drag the Arduino pin down towards 2 volts, pulling more current until the internal resistance of the LED , the wiring,  and the internal chip resistance between them lose the other 3 volts by generating heat.

Everything is now running towards meltdown, we have seen postings saying that people have connected an LED directly between the Arduino pin and ground and it works , sometimes it does for a while, but both the Arduino and the LED are running way over spec.

The right way to do it is to put a resistor in series with the LED,  the Arduino happily supplies 5 volts out, the LED takes its 2 volts, and the resistor is happy to get rid of the other 3 volts.

The beauty is that we can now easily set the current through the LED to its recommended milliamps by Ohms law ( because the same current is passing through the LED and the resistor in series )

So if our particular  2 volt Vf LED is only supposed to handle 20 mA, then the resistor has to drop 3 volts at  20 mA  ( 0.02A ) .

Ohms law tells us  Resistance = Voltage / Current,  so we would need a   3 / 0.02  Ohm resistor = 150 Ohms - which just happens to be an available value.
( If the value is an odd value, rather take the next available value higher and lose a little current rather than overun the led specs . )

You can substitute other values of Vf in the above for different LEDs.

A couple of points :-

Multiply the Vf by the number of LEDs in series ( you will probably need more volts than the Arduino can supply so will need a buffer ( a transistor or ULN2003 type chip - do a search )

You will be extremely lucky to put 2 LEDs in parallel and get the same light from each, as the Vf varies slightly from batch to batch, so each LED ( or string of LEDs in series ) needs its own resistor.  ( unless you are using a constant current generator driver )

If you are using a 7 segment display, [and you are not multiplexing the segments, that is, all segments may be driven on together],  you cannot have a single resistor in the common anode or cathode connection and expect a steady brightness for each displayed number  , as the resistor would drop a different voltage depending on how many segments are lit  ( one segment for "1" ,   3 segments for "7"  and all 7 for "8"  )


Jack Christensen

Good explanation there!

My rules of thumb when just experimenting on a breadboard with typical 3mm or 5mm LEDs (and assuming a 5V supply):

1. 330? is a good starting value. This usually results in 9-10mA of current, so if I want to connect LEDs to several pins, I don't have to worry about the AVR's aggregate current limitations. Many LEDs are plenty bright at this current; some can be very bright.

2. 1000? is a good value to limit current even further, and will still provide enough to drive many LEDs to adequate brightness.

3. For experimenting or prototyping, it doesn't have to be rocket science.
Anything between 150? and 1000? should work. For more serious work, or just as an educational exercise, go ahead and do the math and get the meter out.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

CrossRoads

#2
Oct 15, 2012, 09:55 pm Last Edit: Oct 15, 2012, 09:59 pm by CrossRoads Reason: 1
Add to this:
"If you are using a 7 segment display [and you are not multiplexing the segments, that is, all segments may be driven on together], you cannot have a single resistor in the common anode or cathode connection and expect a steady brightness for each displayed number, as the resistor would drop a different voltage depending on how many segments are lit  ( one segment for "1" ,   3 segments for "7"  and all 7 for "8"  ) "

Add to this:
"Multiply the Vf by the number of LEDs in series ( you will probably need more volts than the Arduino can supply so will need a buffer ( a transistor or ULN2003 type chip - do a search )
Note that the buffer will dissipate some voltage as well, typically 0.7V for an NPN transistor, and Rds * LED current for an N-channel MOSFET. Read your parts spec for Vce or Rds.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Jack Christensen


"If you are using a 7 segment display [and you are not multiplexing the segments, that is, all segments may be driven on together], you cannot have a single resistor in the common anode or cathode connection and expect a steady brightness for each displayed number, as the resistor would drop a different voltage depending on how many segments are lit  ( one segment for "1" ,   3 segments for "7"  and all 7 for "8"  ) "


Even in a multiplexed situation, a single resistor on the common lead is bad design. Of course, if some driver chip such as a MAX72xx is used, then no resistors may be required at all.

Are the segments multiplexed or the digits? ;)
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

dhenry

The issue here really isn't about resistors. Because of led's negative tempco, you want to have a means to set the current for the led. The resistor is a cheap approach to provide feedback. Other approaches can also work, for example, with a ccs driver, a current diode, or even sampling approach (in a switching mode led driver).

Quote
Even in a multiplexed situation, a single resistor on the common lead is bad design.


What's good / bad is subjective. There are cases where a single resistor (or even no resistor) makes sense. However, the single resistor approach does have its own limitations: uneven brightness, or tolerance on the led's Vfwd inconsistency.

Osgeld

it totally depends in reality

if you want a generic answer 150-330 ohm for a few, a k for a small pile

driving white LED's at exactly 26 lumen your going to have to break out the datasheet and excel to make a calc and charting program to even have a clue 
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Boffin1

I did say
Quote
heres a little simplified basic understanding.
:-)

Boffin1

Something that comes up is about the regulation of power supplies for LED displays,   Generally :-

If you are using a resistor in each chain of LEDs with a transistor or driver chip grounding the chains -  You need a
regulated power supply - as per your calculations.

If you are using a constant current driving circuit,  the power supply must be able to supply enough voltage for the maximum current with all LEDs on.

Too much extra voltage will cause heating in the driver circuit, so select the next voltage up from needed.

Go Up