NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Do LEDs need a series resistor to limit the current?

April 08, 2009
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

One common question we hear is whether you need to put a resistor in series with an LED to limit the current. Well, the answer isn't a clear yes or no -- it depends.

Normal LEDs like the ones included in your kit are rated for about 20-50mA maximum current. However, LEDs are not like resistors, because their current-voltage curve (like we discuss near the beginning of The NerdKits Guide) is extremely non-linear. The current is almost zero until you reach its forward voltage of about 2.0V, and then increases very rapidly, to a level where applying even 2.5V would cause so much current to flow that the LED's active area would simply destroy itself (by heating up rapidly and melting!).

So how can we effectively use a device where 1.8V would cause it to not light at all, and 2.2V might cause it to destroy itself? A 10% change on either side could be catastrophic. This seems like a difficult challenge, but the trick is to put the LED in series with some device whose current-voltage relationship is much more manageable.

When you put any two devices in series, and then measure the resulting combined device, the same current has to flow through both, but the voltage drops add together. Therefore, you can take the current-voltage curves of both devices, and add them along the voltage axis! So instead of having a very steep area around 2.0V, the LED+resistor will have a curve that looks like the resistor's current-voltage curve shifted over by about 2.0V. So if you want 20mA to flow through your LED, powered by a 5V source, you need a series resistor that's (5.0 - 2.0)/0.020 = 150 ohms.

Back to the original question...

If you are driving an LED directly from a battery, or from the 5V regulator, then the answer is likely yes, you need a series resistor. This is because the internal resistance of the power supply (whether battery or 5V regulator) is much less than 150 ohms.

But, if you are driving the LED from a microcontroller pin, the answer is not necessarily. Buried in the back of the ATmega168 datasheet, you'll find Figure 29-22 (page 328) and Figure 29-25 (page 330), which are the current-voltage curves of the microcontroller output pins themselves. They're not perfectly linear, but drawing a line and estimating the slope, the "source" resistance (which is when the output is high) is about (5.0-3.0)/0.065 = 30.8 ohms, and the "sink" resistance (which is when the output is low) is about (2.0-0.0)/0.075 = 26.6 ohms.

So if you're driving an LED's anode from a microcontroller pin, with the cathode connected to ground, you'll run about (5.0-2.0)/30.8 = 97mA through the LED. This is a bit more than the rated current of either the LED or the microcontroller, but ultimately it works, especially if you use PWM to modulate the brightness. For example, in the LED Marquee project, each LED is only on for 1/10th of the time, and the current must go through both the sink and source resistances of the microcontroller so the "average" current through any one LED is at most (5.0-2.0)/(30.8+26.6) = 5.2 mA, well below the maximum rated current.

Still, you can use a series resistor with the microcontroller pin too, and this will help you control the brightness and manage the power consumption of your circuit, especially if you aren't going to be modulating the brightness of the LED.

Hope that helps!

Mike

April 11, 2009
by ranger
ranger's Avatar

Thanks!

(currently watching my LEDs "bounce the light" back and forth...)

April 11, 2009
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Great! Note that if you aren't using PWM or otherwise limiting the average current to the LEDs, I still recommend a series resistor (or just do PWM). Otherwise, you could very well see excess heating of your LEDs, and a consequent permanent degradation in their performance.. But if you're "bouncing" between several different LEDs, then you're almost certainly safe.

Mike

April 14, 2009
by ranger
ranger's Avatar

...are the 6 resistors included with the nerdkit series resistors? I tried putting one inbetween an LED and the MCU pin, but the light is kinda dim.

April 14, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Ranger,

Your question is one that I think you can answer yourself. A resistor is just a resistor, you just gotta make sure you are using the right one. The resistors we include with the kit are of different resistance values, the brightness of the LED will depend on which resistor you use. The updated version of the guide has a section on resistor values, you can download the new version from our downloads section. (or just google for resistor color codes)

If you are using a resistor in series with your LED: As mrobbins mentioned above your LED will be dropping about 2V when it is on. The MCU is running off 5V, 2V get dropped in your LED, so this means 5-2 volts are left for your resistor. Since you are hooking up your resistor in series with your LED, the same current has to go through both devices. You also know that V=IR, So (5-2)/(your resistor value) will be the current going through your LED. Like mrobbins mentioned above, there is some resistance due to the MCU pins themselves. You are shooting for somewhere between 20-50mA. What current were you running through your LED?

Humberto

April 16, 2009
by ranger
ranger's Avatar

Alright, I think I'm finally starting to understand this :)

June 14, 2009
by BobaMosfet
BobaMosfet's Avatar

hevans,

We actually have another discussion going on here regarding which side of the LED to put the resistor on. My understanding and intuition says to put the resistor on the cathode side of the LED. Certainly in a parallel circuit I would think, but does it matter in a series circuit? I think you'd want to limit the current and lower the voltage BEFORE it gets to the LED... but in a series circuit a resistor will limit the current and voltage in the entire circuit, so perhaps it doesn't matter which side it's on.

June 10, 2010
by pulsifer
pulsifer's Avatar

Using a 100 ohm resistor gives good brightness and should extend the life of your battery, LEDs and port pins.

June 12, 2010
by BobaMosfet
BobaMosfet's Avatar

By the way, to add one more thing, yes you can put the resistor on either side of the LED. It's in SERIES so it doesn't matter.

BM

December 14, 2010
by danuke
danuke's Avatar

I have seen LEDs that have colored epoxy, like those that came with the kit, and then LEDs that have clear epoxy but are labeled as various colors. So other than the difference in price, what is the major difference and application use in them. Thanks, DN

December 14, 2010
by Ralphxyz
Ralphxyz's Avatar

And speaking of LEDs and resistors, would I need one resistor or ten resistors to light 10 leds at the same time?

There would be a common anode so could I use just one resistor?

Ralph

December 14, 2010
by mongo
mongo's Avatar

If they are parallel, I would suggest individual resistors. This is because some may not quite match the others and you would have bright and dim LED's all together. Another thought would be a regulator type circuit that provides the forward voltage of the LED's and not much more than that. With the right voltage, each LED would take the current it was designed for.

If you are using a power supply in the circuit with the voltage, putting some in series can reduce the number of resistors.

I built a tail light which has four LED's in series with a resistor. When I hit them with 8 volts, they are lit but not brightly. With 12 volts, they are full brightness. I use an 8 volt regulator for the parking lights. The same LED's for the brake/turn signal when the 12 volts goes to them. The current flow will just take the higher voltage.

December 14, 2010
by danuke
danuke's Avatar

If they are in series, then only one resistor; if parallel, then one for each.

December 14, 2010
by danuke
danuke's Avatar

re resistors again. this once again got me to thinking about the colored epoxy type vs the clear epoxy but color emitting LEDs. I bet that the color epoxy LEDs emit the same color and the color comes from the epoxy, so far I have never gotten any data sheets with them. they are really cheap and I get them in packages of multiple colors, usually cheaper than what one or two of the other kind of LEDs cost; however those LEDs do have specs on the packages.

NOTE: even the higher dollar red LEDs are colored, I still have to study on this, but I cant but help if it is an energy/frequency thing; red is really low - finding blue, yellow, purple not a problem.

December 14, 2010
by danuke
danuke's Avatar

Well, after all this resistor talk, just for fun, I put a green LED across a 9V battery to watch what would happen.

First there was a fairly bright orange glow at the bottom of the LED, which gradually dimmed, then there were two bright flashes of white light, and that was all she wrote.

December 14, 2010
by BobaMosfet
BobaMosfet's Avatar

The coloring in the epoxy is usually more for us, than for the diode itself.

BM

December 14, 2010
by Ralphxyz
Ralphxyz's Avatar

danuke, did you not use a resistor?

Regarding if the resistor should go before or after the led. I blew a led once that had the resistor before the led by just accidentally touching the red lead from the USB-Serial cable to the anode while plugging in the cable. If the resistor had been to ground instead of before the led there would not have been a problem, the led would have just lit but without the resistor it fried. It does make pretty popping colors when one blows.

Ralph

December 15, 2010
by Rick_S
Rick_S's Avatar

It doesn't matter if the resistor is before or after the LED. In a series circuit, the current flows evenly through all the components.

Also, as to the one or 10 resistors, I agree with mongo and danuke. For instance on a common anode 7 segment display, you would use a resistor on each of the segments not just one on the common anode/cathode. Otherwise, like mongo said you will see a noticable different level of brightness as more or less are turned on.

Rick

December 15, 2010
by Ralphxyz
Ralphxyz's Avatar

Just for safety sake (of the led) it is better to have the led to ground after the led to make sure "accidents" do not happen.

I am going to make up a light string of about 20 leds. I was going to just push the leds into some zip wire and put a resistor

on one lead. Putting a resistor on each led would be a pain. Maybe I could bend them back to get the same length to insert into the wire.

Ralph

December 15, 2010
by mongo
mongo's Avatar

What voltage are you looking at to operate the string?

I took apart a Christmas light set and found no resistors. It had a constant current source instead. I have a schematic for one and the formulas for various current outputs.

What it does is give you the 20 mA that you need and if you have a bunch of LED's in series, as long as the incoming voltage is higher than the 2V(approx) voltage each LED needs, they would all light up with the same current. (20 LED's would need at least 40 volts) My light string had 60 LED's and was supplied with 120V and it was right on the money at 20 mA for the entire string. They did have a little strobe effect because they worked only on one half wave of the 60 Hz but it's not noticed unless there is motion.

December 15, 2010
by Ralphxyz
Ralphxyz's Avatar

Mongo, probable 12 - 16 volts I have a heavy 16v 6amp pda power supply.

I have not done any of the math, so I really haven't thought this through yet.

I just have this need where a string of leds is operated by a motion detector.

So far it is just an on off probable with an on time delay of 10-15 minutes.

I haven't even thought of what I would need as the time source.

A manual on off would also be nice.

I like the constant current source. I could add some brains and use the Nerdkit to control the leds.

Could you publish the constant current schematic?

Ralph

December 16, 2010
by mongo
mongo's Avatar

I'll get a picture up on Saturday when I get the camera back into shape. I'll post it here.

December 18, 2010
by danuke
danuke's Avatar

Ralph, No, I did not use a resistor. Like I said, I did it for fun just to see what would happen. ;^) DN

December 18, 2010
by mongo
mongo's Avatar

I found a website that has the same circuit that I have been using for years. Instead of posting another picture, I'll just stick the link here. Two transistors, two resistors, Wide voltage range and can be built on from there.

constant current link

December 18, 2010
by Ralphxyz
Ralphxyz's Avatar

What would I do for a string of 20 parallel leds?

The constant current device illustrated is for one led.

Ralph

December 18, 2010
by bretm
bretm's Avatar

Can you put them in series instead? That way they'll automatically have the same current, just be sure you give it enough voltage. In parallel, variances in LED manufacturing will cause different current for each one, and you'll need a lot more current. Higher voltage is often easier to come by.

December 19, 2010
by mongo
mongo's Avatar

If you use transistors rated for the voltage, you can string up about 50 0r 60 in series off the one limiter setup. The transistors shown are low voltage rated units. 50 LED's would require about 104 volts DC. You can use AC but will need a diode like a 1N4007 in series with the circuit as well. Just remember, it takes about 2 volts per LED plus a couple for losses. I have a formula for different current values to select the right resistors but I think it is also in the text of the linked site. I used the circuit with two 2N2222 transistors to drive a bright white LED with 40 mA and it worked great at any voltage between 5 and 20 volts. The transistors do get warm so it is best to keep the voltage reasonably close to the LED voltage.

Post a Reply

Please log in to post a reply.

Did you know that two resistors plus a transistor can be used to make a better voltage supply? Learn more...