While there are lots of pages on the web that tell you how to calculate a current limiting resistor for an LED, this one tells you the foundations of the calculations.


Most beginners start out exploring electronics and embedded control by making an LED do something. This is great it’s easy to wire up and you can actually see something happening. With an Arduino you only need one LED and one resistor and their are lots of examples around. Unfortunately their is also a lot of confusion, muddle and downright rubbish about such a simple thing. This page give you the truth and reasons behind the calculations you need to do.


The care and feeding of LEDs

What is an LED?

LED stands for Light Emitting Diode, a diode is a circuit element that will let electricity flow through it in only one direction and when it flows in an LED it also emits light. The light is a colour that is determined by the materials it is made from and different colours can be manufactured. These days all colours can be fabricated but it wasn’t always the case. Early LEDs were only red or infra red. Then along came green, yellow and finally blue and white. In fact white LEDs are normally ultra violet LEDs illuminating a phosphors material rather like a miniature florescent  tube. The ultimate for colour is the RGB LED, that is three separate LEDs in one package each one being one of the additive primary colours of Red, Green and Blue. By mixing these three colours you can get any colour you like.

There are a great number of different types of LED about with a great variety of package, brightness and power. The simplest ones to use are the low power ones only taking a few milliamps, this page looks at those types.


How to power an LED

LEDs are not like normally electronic devices in that you can’t just apply a voltage to them and they work, they have to be fed the correct voltage and current to keep them happy. Whenever we encounter voltage and current in electronics the Ohms law in not far behind.

First of lets see what ohms law actually says:-

"The voltage across something conducting electricity (V) is proportional to the current (I) through it."

so V is proportional to I

Like all math we can make the "proportion" bit into an equals if we put in a constant of proportionality, like this:-

V = k * I

The constant of proportionality is called "resistance" and so we write :-

V = R * I

This works well for substances when there is a linear relationship between voltage and current, things like metals, carbon an metal oxides. We say these are linear substances, so if we double the voltage we will double the current. The graph of voltage against current is simply a straight line, with the slope of the line being the resistance.

Now consider a substance where "The voltage across something conducting electricity is NOT proportional to the current through it." This is called a non linear substance. Take for example the filament in a flashlight bulb. When it is cold it has a low resistance but when it is glowing white hot it has a high resistance. The resistance is now some function of the current. We could write:-

V = f(I) * I

In words this is the voltage across it is equal to some function of the current times the current. The resistance has dropped out. Of course you could just write:-

V = R * f(I) * I

In effect extracting a constant out of the function. In the case of a flash light bulb we can do that and quote the resistance at various currents or temperatures.

Now an LED is a device the ideally has no current flowing through it, that is it looks like an infinite resistance, when the voltage across it is below it's "turn on voltage". When the voltage across it reaches this point it all of a sudden has no resistance or looks like a short circuit. So how do we deal with that with ohms law?

Well we can't. So instead we say that if we have a resistor and LED in series we know that the same current flows through both devices. The voltage across the resistor will be proportional to the current through it AND the current through the LED is the same as the current through the resistor. We know the LED will have it's turn on voltage across it so we can express ohms law for the resistor as:-

V_total - Vled_turn_on = R * I

Therefore we can calculate the value of resistor we need to use to get the current we want. Remember that resistors only come in discrete values, so you have to pick the value that is closest to the one you calculate. You could then go back and repeat the calculations and see what current you will really have when you build the circuit. In many cases this does not matter as the difference between the value you want and the one you can get is small compared to the overall value.

It would be wrong to think of the LED as having a resistance that is independent of the resistor. The LED does have and "equivalent" resistance, but it's value is wholly dependent on the value of the current flowing through the LED and dynamically changes with it.

In practice the voltage / current graph of an LED is not a right angled curve but something a bit smoother, like that show on the right. This is a gentle curve different devices can show different degrees of slope. This is normally taken account of when calculating current limiting resistors as you normally take the on voltage at the current you want from the graph or the data sheet.


Note that these calculations only really work for when the resistor is dropping a good percentage, at least half, of the voltage across it. It is also only valid if the resulting resistor is not too low, say above 50R. If the resistor is lower than this it is likely you are trying to use a power LED, one taking over 60mA. These need feeding with a constant current supply and are not well suited to just using a resistor. Powering these sorts of LEDs is outside the scope of this page.



LED abuse

There are several web sites and schematics on the web that suggest you can attach an LED directly to an Arduino output pin with no current limiting resistor. They are wrong, and following them will damage your Arduino. Their logic goes something like “the arduino will limit the current” or “as you are multiplexing the LED (turning it on and off rapidly) the circuit won’t heat up enough to burn anything out”.

They are wrong.

One justification says “well I tried it for months and nothing has burn’t out”! This is just like saying I have crossed the road blindfold and I am not dead. What you are doing, if you insist on not having a current limiting device in an LED, is to over stress either the Arduino output pin or the LED, possibly both. True, the LED has a pulsed current rating, these are normally based on turning it on in short pulses for only about one tenth of the time. This rating will be in the data sheet and can typically be between 60 and 120mA, where as the normal continuous current  is typically 20mA. The Arduino output pin has an absolute limit of 40mA, and even taking that from the pin for a sustained length of time will kill it. So how much can you get out of an Arduino pin if you don’t put any resistance in the LED? Well I don’t know because I am not that silly.

But, for an experiment I arranged a stress test with very short pulses of current and I did the test very quickly. I arrange an LED and resistor in series and measured the voltage across the resistor so allowing me to calculate the current. I couldn't reduce the resistor to zero because there would be nothing to measure the current with, however, they were very much smaller resistors than you would calculate for normal use. I used a 75R, 22R, 10R and 4R7, and the results are shown in the graph.

Do not try this at home!

You can see the current approached 300mA without showing any sign of levelling off. Eventually it would have, due to the current limiting resistance in the Arduino leads, and if it had not been a pulsed current the the whole thing would have quickly melted down.  Does my Arduino still work after this? Yes it does! Have I permanently damaged it? You bet I have!

So why does it still work? Stressing a device is just like stressing anything else you won’t necessarily break it but you will shorten its life. The LED was stressed for a start it is likely that this will fail, maybe it’s life will have been shortened by as much as a quarter or a fifth, it is really difficult to say, but I won’t be building it into any permanent equipment. Same goes for the Arduino, although I know it is only one pin, so if I make anything that doesn't use that pin, then I could use the chip. Anything put under excessive stress, including us, will not last as long.


Damage assessment

What damage has been done

There are several effects of over current on a semiconductor device let’s examine them:-

  1. 1)Heat - too much current generates too much heat and the chip or more likely the bonding wires simply melt. Or if not enough to melt then they can weaken the joints of where the bonding wire attaches to the substrate inside the chip. I tried to mitigate against this by having a very rapid current pulse, but it will have weakened it.

  2. 2)Galvanic shock - When current moves through a wire it generates a magnetic field, this can interact with other close by wires, and there will be a mechanical attraction or repulsion force that can again weaken the wire bonds or snap the wires.

  3. 3)Depletion of carriers - Semiconductors work by manipulating charge carriers and having too high a current density can reduce the number of free carriers to a stage where it stops working or it’s resistance increases so the internal temperature rises, possibly to a dangerous level.

Other abuse

The voltage myth

There is another myth about LEDs, this one says that you do not need any current limiting if you feed it with the correct voltage. This one is extremely silly because the protagonists say you just have to supply the forward voltage to the LED. Well by the time you have supplied a variable voltage source you have used far more expensive components that a resistor. Even so the problem is that the forward voltage quoted in the data sheet is not one voltage, but a range of voltages that applies to that device. Any individual LED can have a forward voltage anywhere in that range. What is worse is that this forward voltage changes with temperature and with the age of the LED so it is not stable. Also, as you can see from a typical voltage current curve this slope is very high and you have to precisely control the voltage to avoid exceeding the maximum current. Therefore any change in the forward voltage has a disproportional effect on the current.


What can we learn

  1. 1)We can damage things without totally destroying them, but the damage show up in reduced lifetime or decreased reliability.

  2. 2) Just because a design works does not make it a good design.

  3. 3) Always keep all the parameters in a circuit design to within those specified in the data sheet.