Driving an LED with or without a resistor

In this post I will try to show, why it’s a good idea to use a current limiting resistor for an LED. And when it’s save to drive the LED without any resistor.

If you read about LEDs, you will notice that everyone tells you, that you need a current limiting resistor. But mostly they do not tell you why.

LED with current limiting resistor

If you look at a datasheet of an LED, you will notice that graphs shown are not linear. An LED is a diode, a semiconductor and behaves differently compared to a resistor.

If you apply a specific voltage to a resistor, you can compute the resulting current with:


I = V / R Example: I = 5 Volt / 100 Ohm = 50 mA

Obviously that does not work with LEDs because they don’t behave like a linear resistor. If you look at the graph above, you can rise the voltage from 0 Volt to 1.6 Volt without resulting in noticeable current. Apply a bit more voltage and there is current and the LED lights up. We have reached the Forward Voltage which is needed to open the pn-gate. Forward Voltage (VF) for a typical red LED is 1.7 to 2.2 Volt. Now small changes in the voltage produce large effects on the resulting forward current (IF). Datasheets normally state at least the absolute maximum ratings for IF, eg. 25 mA. If you apply a voltage that results in a larger current, the LED may be destroyed.

So it’s vital to stay within the limits of the LED. If you would attach an LED to a 5 Volt power supply directly, you would burn it instantly. The high current would destroy the pn-gate. That’s the point where the current limiting resistor comes in.

Assuming, we have a red LED with maximum rating of IF: 25 mA at VF: 2.1 Volt. Its VF related to IF is like the curve in the graph at the top. If we want to use it at 5 Volt, we have to use a resistor to dissipate the remaining 2.9 Volt. To compute the resitor, we use:


R = V / I = (5 Volt - 2.1 Volt) / 25 mA = 116 Ohm.

To be safe we use a 120, or better, 150 Ohm resistor. That way we don’t drive the LED near it’s maximum rating. We choose 20 mA, take a look at the curve and see a corresponding VF of 2 Volts. Now we recalculate the resistor.


R = V / I = (5 Volt - 2 Volt) / 20 mA = 150 Ohm.

Ok, 150 Ohm is fine. To be safe with the resistor, we have to take a look at the power dissipation. It calculates as:


P = V * I = 3 Volt * 20 mA = 60 mW

So it’s safe to choose a 150 Ohm resistor with 1/4 Watt rating.

Ok, so far the typical use of an LED with an current limitting resistor.

LED without current limitting resistor

First of all, why would you want to get rid of the resistor? There are two reasons. First is, it wastes energy. It converts electrical energy into heat. But we want to light up an LED. Not good. Second is, you can reduce the number of components. The circuit gets cheaper, because we saved a resistor and maybe space on a PCB.

There are two ways to bypass the resistor. One way is to lower the input voltage. If you are able to run your complete circuit with the same voltage as forward voltage of the LED, perfect. No resistor needed.

Another method is to use pulse width modulation (PWM). That means we are switching the LED on and off. If we are switching fast enough, the human eye can not tell the difference. It integrates the brightness over time, so to speak. Often there is a Peak Forward Current (IF(peak)) rating in the datasheet. As an example:

IF(peak) = 160 mA
Condition: Pulse Width <= 1 msec and Duty <= 1/10

Which means, it is safe to switch the LED with 1 kHz, where the LED is on for 0.1 msec and off for 0.9 msecs.

Most of the times there is no voltage given for IF(peak), so we can not be sure at what voltage we will reach the 160 mA in the example. Looking at the graph, I would assume that you could go up to 3 V, maybe 3.2 V, but I haven’t tested it out.

I used both methods for my 64pixels, where I attached an LED matrix directly to a microcontroller without any current limitting resistors.

The input voltage is 3 Volts, if used with 2 AA batteries or about 2.4 Volts with 2 AA rechargeables. That helps to get closer to VF of the LEDs.

The matrix lets you address only one row at a time. So you set all column bits for row one and enable row one. Then you disable row one, set all bits for row two and enable row two, and so on. So you are cycling through all rows. This is done so fast, that you wont see any flickering. Every row is updated with nearly 2 kHz and with a duty cycle of 1/8 (because of the 8 rows).

If you are using a microcontroller for driving an LED or LED matrix, you have to take care of the current ratings of the microcontroller as well. Every I/O pin can only deliver (source) or receive (sink) a specific amount of current. I used an ATtiny2313 and from the datasheet on page 181, I read

Absolute Maximum Ratings:
* DC Current per I/O pin: 40.0 mA

And on page 182 as a note:

4. Although each I/O port can sink more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed: 1] The sum of all IOL, for all ports, should not exceed 60 mA. If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.

As I understand that, if you are trying to source or sink more than 10 mA, the voltage VOL (Output Low Voltage) or VOH (Output High-voltage) may drop or rise and exeed the specified values.

Looking at two graphs from the datasheet may help to clear things up.

This figure shows how the output voltage of a source pin is related to the current that it sources at 2.7 V input voltage. 2.7 is not 3 Volts as 2 AA cells can deliver, but close enough for now. What we see, is that the output voltage drops, if we demand more and more current. At 5 mA we have a voltage of 2.5 Volts, but at 15 mA the voltage drops to 2.1 Volts.

This figure shows how the output voltage of a sink pin is related to the current that it sinks. This time the ouput voltage rises, if we demand the pin to sink more current. At 5 mA the voltage is 0.15 Volts but rises to 0.5 Volts at 15 mA.

To check if we are using the ATtiny2313 and the matrix within their specifications, we have to do some math. For the matrix, there is no datasheet with nice graphs but some numbers.

Forward Voltage: 1.80 – 2.20 V
Maximum Rating: Forward Current: 25 mA

We assume the LED runs at 1.8 Volts with 5 mA. That looks reasonable when you take a look at other datasheets. Now, if we insert the 5 mA into the two figures above, we get: 2.5 Volt for the source pin and 0.15 V for the sink pin.


2.5 V - 0.15 V = 2.35 V

So we get that 2.35 V is left for the LED. That is more than we have assumed (1.8 V). Higher voltage for the LED means more current. So this time we will compute with 10 mA. Inserting that again, we get 2.3 V for the source pin and 0.3 V for the sink pin.


2.3 V - 0.3 V = 2.0 V

As you see, if the voltage over the LED rises, the current through it raises as well. But the rising current results in lower/higher output voltage from the source/sink pin. And that means lower current. It is, as if they are fighting each other.

2.0 V at 10 mA looks ok for the LED and the microcontroller.

That was one LED on two I/O pins. What, if we want to control a complete row of eight LEDs?

This time eight source pins, eight LEDs and one sink pin. From the example above, 10 mA per LED sums up to 80 mA (!). That’s a lot. Looking it up on the figure is not even possible. Lets assume, it all sums up to only 25 mA, that would be 3.125 mA per LED. That gives us 2.6 V at every source pin and 1.0 V for the single sink pin.


2.6 V - 1.0 V = 1.6 V

That means, 1.6 V is left for every LED, we are a bit beneath the forward voltage of the LED. So the LED may be a bit dimmer. Again, if the LEDs would suck more current, the microcontroller would deliver less output voltage for the LEDs.

If you look thoroughly at the 64 pixels display, you may notice, that the rows with few pixels lit are a bit brighter than the others.

After all this computing and datasheet staring I think it is safe to let out the current limiting resistor in some cases. You have to take a closer look at specs to get an idea on how it will work out.

If I get something wrong or mixed things up, please feel free to comment on this.

Links

57 Comments

  1. ,,If you are able to run your complete circuit with the same voltage as forward voltage of the LED, perfect.”

    It’s worth mentioning that this would be really difficult to either control the brightness or drive the LEDs safely because the current change would still be big even with small variations of the voltage.

    Like

  2. Oh. And it’s good to know that LEDs last longer when used in a pulsed mode like the one you propose. :)

    Like

  3. Yes, that’s right. Although for most applications the brightness of an LED is not that critical.

    Like

  4. “I = R/V Example: I = 100 Ohm / 5 Volt = 20 mA”

    Are you sure? :-)

    Increasing the voltage decreases the current, huh?

    5 volts across 100 ohm should give 50 mA, of course.

    I first looked at the graph and saw 100 ohm, 10 mA, 2.5 V, and thought where does the funny number come from? That made me look closer at the text.

    Like

  5. Great explanation. Thanks Alex! I have a related question — trying to build some snapcircuit type toys for kids. How can I put in protection circuitry at the LED level to avoid the user plugging in current in the wrong direction?

    Like

  6. You could use a protection diode. That would protect your circuit against false polarity.

    Like

  7. You got me thinking now. If I put two LED’s in opposite direction in parallel, either one will light depending on the input polarity. This will also give a hint and teach about DC polarity ! (This will be for a discovery type toy for young kids).

    Like

  8. High powered LEDs come with an internal resistance too. Ive built a few high powered flashlights for friends and have gone without resistors by changing the number of batteries and arranging batteries/LEDs in parallel or serial to get the desired voltage and current based on the internal resistances.

    Like

  9. @bfg, it would be helpful, if you include a bit more explanations in your comments. Thanks.

    Like

  10. There are LEDs out there with internal resistors. These LEDs can be connected directly to e.g. 5 volts.

    Like

  11. hey thanks for the article. In the first two green equations where you calculate the resistor value, where does the 2v and 20mA come from in the second equation?

    Like

  12. The values were taken from an LED datasheet. It has the same curve as the one in the graph at the top. I decided to go with less current (20 mA) to not drive the LED at its maximum and looked at what voltage that would happen (2 V). Then I recalculated the resistor.

    Like

  13. Im trying to switch my stock fog lights to LED lights, but the LED lights are not as bright as a regular bulb. How can I make it brighter? Is that happening because of some resistor in my car? Thank you

    Like

  14. Hi Lucas,
    there are many different kind of LEDs out there. Maybe try one of these high power LEDs. And you definitely need a current limitting resistor in that sort of circuit. Even high power LEDs are far from handling 12 V.
    Cheers,
    Alex

    Like

  15. Another good way to get light instead of warming up a resistor is simply to use LED’s in series. I have used 5 red LED’s in series on a 9V battery with no resistor. Current was in the normal range. Or, 2 white and 1 red. Whites LED’s drop about 3.4V, red drop about 1.6. 3.4 + 3.4 + 1.6 = 8.4V, and that is close to the actual voltage of a 9V battery. One problem I have had is measuring the current; A meter will change the value! So now I attach a CdS photocell to one LED and measure the brightness (as indicated by the resistance of the CdS cell) at the desired current. Then in the circuit I can see if it is brighter, meaning more current.

    Like

  16. Pingback: Blinking the leds
  17. “And if the brightness should be constant, I think a current source would be a good choice. http://en.wikipedia.org/wiki/Current_source

    A current source does exactly the same thing as a current-limiting resistor, in this application. The load isn’t changing, so the current doesn’t need to be regulated. It just makes a transistor act as a resistor to limit the current to a preset value. Waste of energy and money.

    Like

  18. Hi Steve,
    as far as I know, all commercial available LED driver ICs are in fact current sources. I also would think that this is the right way to go, since the save limiting factor for the LED is the current not the voltage. And good current sources also have a very high efficiency. But you probably can not reach such high efficiency with the simple one transistor circuits mentioned in the wikipedia article.
    An additional advantage of such a driver is that you can use it within a wide range of input voltages.

    greetings

    Thorsten

    Like

  19. I would think that a current limiting resistor is ALWAYS required, even if Vsource = Vf.

    One main reason I can think of is the negative temperature coefficient of a Diode. If a Diode heats up, it’s internal resistance decreases and thus it will sink more current thus heating the diode even further thus… Thermal Runaway.

    This leads to high currents and burnt leds!

    Like

  20. Upon all my lab testing so far, I haven’t seen the need for the current resistors with the super bright LED’s that I have purchased on E-bay for R&D. All of my lab test that I have performed I have kept the FV in respect to the LEDs voltage ratings, 3.2 volts or so.
    The latest test is still under way, I’ve link 4 LED’s in series and have them connected to a freshly charged 12+ volt 500 CCA car battery, They’ve been lit for over a week now, and still glowing bright as the day I hooked them up. I have put my test meter in line set to measure amps, set at 200ma scale, it shows a draw at 8-10 milli amps “cheap volt meter I think is cause of fluctuation”.

    I havent seen thermal runaway yet in the above test, but its only been a week now. Im really hoping to see it to prove some of you guys right.

    I agree with some of the others here, if you plop resistors in when not needed your wasting power. If your building a project build it around the source your going to use. Obviously if your source is unstable then resistors will be needed to keep your voltages in specs with MY current test LED’s, I haven’t seen the need for current limiting while running at 3.2 volts.

    From some of the people that post here, I think you need to put the pencil down, and get into the lab and perform your own tests and conclusions, 200 Super brights for 10 bucks on the E-bay free shipping. Have fun and pop a few of them if you can and learn while doing so.

    Like

  21. Good article specially driving led without resistance by using PWM

    Like

  22. Also, power supplies always have internal resistance. Some, like CR2032 cells (see throwies) and 9V stacks have ridiculously high R and so often can’t put out enough current to damage many LEDs if they tried.

    Like

  23. Great article!
    I have to test the same thing; driving white LED with button cells without a resistor but i dont know how can i measure the current.
    @KentD, can you please explain how can i measure the current with CdS photocell, or refer some website where i can learn about it.
    The internal resistance of button cells is also unknown, is there any way one can measure the internal resistance of a button cell.
    Kindly help; measuring internal resistance of the battery and the current through the diode are my tasks and i’ve got no clue.

    Like

  24. Great article. I always wondered about why the resistor was there.

    One small thing though … N.S. if I read this correctly, but if you have:
    Pulse Width = 1 msec
    Duty = 1/10
    It’s true that:
    LED is on for 1 msec/off for 9 msecs
    But I think your operating frequency is then 100 Hz instead of 1kHz.

    Like

  25. Hi Rich,
    ms stands for millisecond and milli stands for 1000.
    Cheers,
    Alex

    Like

  26. hello can you ntell me if it is possible to run a 3.2 /3.4 volt warm white of a 3 volt power supply or does it harm the led or would it be not so bright thanks

    Like

  27. To MikeM, 8-10 milliamps is not much, it’s safe to run the led’s at twice that current, you are not working your led’s hard or getting anyhwere near full brightness at such low amps.

    Like

  28. Hi Alex!

    nice tutorial! please tell me if i got it right….

    i want to control a 1W rgb prolight led trough pwm, possibly without a resistor. forward current 150 mA, and peak forward current is 250 mA. According to the graph you reach 250 mA at approximately 4V. My source is a 12V 10Amps supply. Does this mean that even in pulsed mode my supply is not supposed to have more then 4V tension? so basically i MUST add a resistor to drop the voltage from 12 to 4V? I’m quite confused. is it even possible to drive those leds at 12 V with PWM without killing them?

    Like

  29. Hi Igor,
    if you hook up your LED with 4V at your 12V supply, you will kill the LED instantly. Even in pulsed mode. For that you need a current limiting resistor. Or you can try to drive more than one LED in series.
    Cheers,
    Alex

    Like

  30. Hello,

    I am making up LED rear lights for my motorcycles (6v positive earth). Thses are not available stock. Using 4 x 235,000 mcd Leds. These are white Leds, obviously shining through a red lens and seem to lose a lot of light once the lens in place. Will I get better light transmission with red Leds?

    Thanks

    Tony

    Like

  31. I was successfully able to hook up a led to a 5V power supply without it burning out. However, it wan not your typical green LED that would use about 2.1V, but rather a high luminous blue one that requires 5v. It’s been without a resistor for several months, and still is working just fine!

    Like

  32. when i try to make a circuit with LEDs (blue+green+red) in series , attached the power supply 12 volts DC, the blue color LEDs are taking the power and become bright, but red and green color LEDs are very dim . please let me know the solution to fix the problem.

    Like

  33. Hi Joy,
    you should check what voltage and ampere each LED uses to full brightness. Maybe driving different LEDs in series is not a good idea. Try to use them in parallel with current limiting resistors.
    Cheers, Alex

    Like

  34. I found it interesting especially for the explanation of why do we need a limiting resistor and the need of PWM.I also have a project on Adaptive color light,which senses an object color(with RGB led) and lights a bulb of the same color for instance if i approach a yellow object to the sensor,the color of a bulb will be also yellow. So, My question is do i need a PWM, since i thought pwm is only to change the brightness of a led,not changing of a color of a light.I will use an AVR ,atmega32 .So could you help me on this things. especially the power circuit,the use of pwm with my respect and led driver. Thanks in advance

    Millideac

    Like

  35. You would need PWM to mix the colors (red, green, blue). So e.g. 90% red + 80 % green + 0 % blue gives some yellow.

    Like

  36. Let’s say I wanted to use LED’s to illuminate a clear trackball that is in my computer. The trackball connects to the computer via USB, which is a 5V dc connection. Theoreticly, If I create a parallel path off of the USB black and red wires, and connect three 1.5 V LED’s in series, is the total 4.5V circuit I create close enough to the 5V power to not need a current limiting resistor? Do you think there is a sufficient power margin in a USB device to drive both the trackball and the installed LED’s without damage to either the trackball or the computer?

    Like

  37. m using 40 LED’s of white color on 12V battery with 750 ohm resistors attached in parallel, its working fine. Most of people say i should use 1k resistors. M nt gud in physics n math. Wat u people suggest ?

    Like

Comments are closed.