LED Tutorial

As I was trying to think of a topic to write on this week, I noticed my ten year old son was playing on my bench trying to light up an LED with a battery. I was mildly entertained as he would smile when the light came on and then frown when it would turn off. “What happened?” he would say. I let him continue for a little while until I realized he was quickly working his way through my inventory of red LED’s.

 What my son didn’t realize is that he was either connecting them backwards and/or not properly limiting the current to the LED in which case he was burning them out. So yes, an idea on what to write about was born. As with most things that we set out to do, we need to understand the components that we’re working with. We don’t need to become an expert on LED’s to use one but some basic understanding is helpful.

 A good place to start with understanding an electrical component is the datasheet. A popular LED is the red 4mm leaded package so we’ll work with that one. Before we get started, it’s important to point out that an LED is a Light Emitting Diode. This means that it is essentially a diode that lights up. And with diodes we know that current can only flow in one direction, that is, the direction the diode is pointing. If you turn it around, no current will flow, and it will not light up. When it’s used in its proper orientation, it will pass current, have a voltage drop, and give off light. The first thing you’ll see in the datasheet is the package drawing. This is, of course, helpful in giving you a feel for the size of the key features of the component but I’d also like you to notice the leads. LED’s have two leads called the Anode and the Cathode. The Anode is the positive terminal and the Cathode is the negative terminal. The longer lead is the Anode. This will help you to properly insert your LED into your breadboard or PCB with the correct polarity.




Another feature of the package is that when you look at the LED from the top, you’ll notice there’s a flat side which corresponds with the shorter lead or Cathode. The schematic for an LED is shown below. Sometimes an LED schematic symbol will be circled but I’m showing the default symbol used in PCB Express Schematic.


I’m not going to go into such topics as Luminous Intensity and Wavelengths in this tutorial but may discuss it in a future article. It’s not that these topics aren’t important, it’s just that my goal here is to get you up and running. With that said, lets move on to sizing your current limiting resistor. What’s a current limiting resistor? Well, it’s the resistor in the small circuit shown below.


Its purpose is to “limit” the current in the circuit so that the LED is fed the proper level for operation. So how does it do that? Let’s take a look at this equation referred to as Ohm’s Law.

V = IxR V = Voltage expressed in Volts I = Current expressed in Amps R = Resistance expressed in Ohms A slight modification to this equation results in the expression … R = V / I So if you know the voltage and the desired current, you can calculate the resistance needed to make that happen. So how do I know what V and I are? Well, let’s go back to the datasheet. You should see a chart similar to the one below.


This chart shows the LED’s characteristic relationship between Forward Voltage and Forward Current. These two values are exactly what we’re looking for. This not only shows the operating range of current and voltage but shows how one affects the other.

One good practice when picking values is to pick values near the middle of the range. This will give you a nice safety margin on both sides. Let’s go back to our LED circuit for a moment. This time, I’ve declared what my battery voltage is. You need to know what this is going to be to select an appropriate resistor. For our circuit, we have selected 5 Volts for the battery.


Now keep in mind that your circuit may not look exactly like this one. Yours may look like the one below.


If your output pins on your PIC are running at 5 volts then your circuit is essentially the same as the one with the battery. If we’re talking about a PIC though, I know one more piece of information which is important. I know that the max current we should have is 20mA. This is the datasheet max for PIC devices. If we go beyond this value for too long, our PIC can get a little toasty.

So after we know our voltage we know all the following… – Our source voltage is 5 Volts – Our max current is 20 mA – The resistor will have a current drop – Our LED will have a voltage drop – I know that the sum of the drop of the Voltage across the Resistor and the LED will equal 5 Volts. Let’s go back to our LED Datasheet chart above. If I pick a value in the middle of the range, say 2 Volts, what is our current (I)? I’m seeing about 8mA which is well within our max of 20mA. So, with a voltage drop across the LED of 2 volts that gives us a voltage drop across the resistor of 3V (5 V – 2 V = 3V). Now we can use our equation for Ohms Law to calculate the value of the resistor that will give is a 3 V drop. R = V / I R = 3 V/ 8 mA R = 375 Ohms So what we’re looking for is a 375 Ohm resistor, which I can tell you without even looking that it doesn’t exist. What we need to do is find the closest value that does exist and recalculate our values to make sure we don’t exceed our requirements. The closest standard resistor value to 375 Ohms is 360 Ohms for a ¼ Watt 5% tolerance resistor. Let’s recalculate using that value and make sure our current is within our operating range. I = V / R I = 3 / 360 I = 8.33ma (Good) Even though I’m pretty sure we’re OK, let’s go ahead and calculate the power that will be consumed by the Resistor in the circuit. The equation for that is… P = VxI P = 3V x 8.33mA P = 0.025 W (Good since limit is 0.25) Now keep in mind that that if you consistently use the same power source and similar PIC’s, you don’t need to recalculate this every time. Just use the same type of LED for most of your projects and buy a bag of resistors of the appropriate value. I tried to explain all this stuff to my son after he systematically worked through a chunk of my red LED’s. He nodded and smiled as I worked through the math but clearly he just wanted me to tell him what resistor to use. I handed him a bag of 360 Ohm resistors and went on my way.

Comments are closed.