Article Index

Calculating An LED Resistor

With just the few ideas introduced in this chapter, and one small extra, you can already do something useful and something you couldn't before - calculate the resistor needed to keep an LED safe. 

An LED - Light Emitting Diode - is one of the basic output devices you will use in building IoT devices. In principle all you have to do is place a voltage across the diode the correct way around and it will light up. 



You can identify the polarity of an LED usually from the flat edge. 

An LED is a strange device compared to a resistor. It is the first example of a non-Ohmic device. Ohmic devices like resistors are very simple - the current through them is proportional to the voltage across them, double the voltage and you double the current. This isn't true for a non-Ohmic device.

For example an red LED has a voltage of about 1.8 to 2.2V across it almost no matter what current is flowing. This is called its forward voltage and yes increasing it does increase the current though the LED but not by much. For practical purposes you can treat the red LED as if it has 1.8 to 2.2V across it independent of the current. The forward voltage is different for different colors of LED. 

If you try to imagine what this sort of behavior would be in terms of water flow then you would probably have to invent something very complicated. Roughly speaking the behavior or an LED would correspond to some sort of water valve that automatically adjusted the flow to always have the same pressure across it. That is if you try to increase the pressure across the valve it will just open more to allow more water to flow to relieve the pressure. 

So it is with the LED. If you try to increase the voltage across an LED it will allow more current to flow in an effort to reduce the voltage. 

As well as having a forward voltage specification LED's also have a peak forward current. If you put more current though the LED than this the result is fried LED. For red LED's the forward current is in the range 20-30mA.

If you don't know the exact values for a red LED, because you just found it in a box of mixed components say, then assume that it has a forward voltage of 1.8V and a forward current of 20mA and then you almost certainly will not destroy it. 

First let's find out how not to connect and LED.

In the diagram below we have a 5V batter connected to an LED.

The question is what is the current in the LED?


If you think about the water flow model for a moment you will realize exactly what is going to happen here. If you recall our earlier statement:

If you try to increase the voltage across an LED it will allow more current to flow in an effort to reduce the voltage. 

In this case the battery is trying to put 5V across the LED so the LED "opens up" and tries to let a lot of electricity though so reducing the voltage. With a theoretical battery the LED would have to allow an infinite current before it saw any effect on the battery voltage. With a real battery the current is limited to however much the battery can supply - if this is more than about 20mA the LED will fail. 

This is not a good way to run an LED. 

The simplest solution is to include a resistor that will limit the current to 20mA. 

The question what value of resistor do you need? To get the answer you have to add one more idea to what you already know. The LED is going to have about 1.8V across it no matter what current is flowing though it.

So what voltage does the resistor have across it? 

The answer is 5 - 1.8 = 4.2V. 

For components connected in series in this way the voltage is divided up between them. This is an idea we return to later.

Now that you know the voltage across the resistor you can work out what value you need to set the current to 20mA. Notice that the current that goes through the resistor has to be the current that does though the LED - it has no where else to go!

Using Ohm's law we have:

R=V/I= 4.2/20= 0.21K Ohms

So now we know we need a 210 Ohm resistor. Of course there is no such thing as a 210 Ohm resistor and the nearest bigger resistor in the E24 series is 240 Ohm. We chose the bigger value because this reduces the current rather than pushing it over the 20mA limit. 


If you build the circuit - or simulate it, see the next chapter - then you will find that rather than 20mA you will probably get something like 14mA but we are erring on the side of safely. The reason for the lower current is that the LED forward voltage is likely to be higher than 1.8V. 

If you follow the calculation you will see that in general the resistor that you need is given by:


Where VSS is the supply voltage, VF the forward voltage and IF the forward current. 

Now you can apply the formula and you know why it works. 


Just to check that you have the idea about current limiting resistors and voltage try the following design problem. 

The question is a difficult one and it is often solved in completely wrong ways so if you get close you have done well. 

Suppose you want to drive two red LEDs in series as shown in the diagram




The question is what is the value of R1 needed to limit the current in the LEDs to 20mA?

You can assume that the forward voltage of both LEDs is 1.8V.


As the voltage across each LED is 1.8V the total voltage across both is 3.6V. The is more to say about how voltage distributes itself across components in series in chapter 3 but this is just like the way the voltage shared itself across the resistor and the LED in the first example.

So if there is. 3.6V across the two LEDs there is only 5-3.6=1.4 across the resistor so to set the current in the resistor to 20mA we need:

R=V/I=1.4/20=0.07 KOhms=70 Ohms.

The closest E24 resistor is 75 Ohms and this makes the predicted current

I=V/R=1.4/75=0.186 or 19mA.

In practice the current is likely to be lower and you can use anything from 50 to 75 Ohms.




This is a chapter from our ebook on electronics as applied to the art of digital design or the IoT. 

The full contents can be seen below. Notice this is a first draft and a work in progress. 

Chapter List

  1. Resistance Is (Not) Futile
    Electronics is a complicated subject with lots of different types of electronic components. Electronics as it is applied to the IoT or digital electronics in general is in fact a much simpler subject. In particular you can master it with a knowledge of just a small number of devices - the resistor being the number one. In this chapter we look at the basic ways that electricity behaves and how resistors control it. 

  2. Meet The Sims - Simulating Circuits
    Electronics is a physical pursuit in the sense that you have to build circuits to test and use them. However there is a lot to be said for using simulation to try things out. Its much easier and you can check that you have correctly designed a circuit before going to the trouble of building it. The good news is that circuit simulation is a lot easier than you might imagine using open source software.

  3. Lowering The Voltage Coming Soon

  4. The Transistor BJT

  5. The FET

  6. Your Workshop - Basic Tools

  7. Driving Simple Loads

  8. Motors

  9. Inputs

  10. DAC

  11. ADC

  12. Logic



comments powered by Disqus