Pages: [1]   Go Down
Author Topic: What resistor for LEDs? Newbies guide  (Read 1681 times)
0 Members and 1 Guest are viewing this topic.
Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 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"  )

« Last Edit: October 16, 2012, 08:06:38 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 91
Posts: 3937
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 512
Posts: 26202
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 15, 2012, 02:59:21 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 91
Posts: 3937
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"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? smiley-wink
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 
Logged


Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

With my mobile phone I can call people and talk to them -  how smart can you get ?

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Pages: [1]   Go Up
Jump to: