Light Emitting Diodes (LEDs) are one of the most fundamental output devices used in open-source projects. They offer you a simple way to provide feedback to a user on the status of what’s going on in a circuit. A popular use is a power indicator to let the user know if a device is on.
However, connecting an LED directly to a power source can cause it to burn out. To protect against this, you must use a current-limiting resistor in series with the LED (Figure 1).
Figure 1: Diagram of a battery-powered LED with a current-limiting resistor. (Source: Mouser Electronics)
Calculating the value of the resistor will require gathering a few bits of information about your LED from its data sheet. Specifically, we will need to determine the LED’s forward voltage (VF) and its maximum current rating (IMAX). VF tells us what voltage is required to bias the LED to turn on. IMAX tells us the maximum current the LED can handle. We also need to know the voltage of the power supply that will be powering the LED. With this information in hand, we can apply the following formula:
Let’s assume the following:
When we apply those variables to the formula, we get the following:
You may be asking yourself, why are you rounding up to 220Ω when the calculation comes out to 165Ω? Simply put, this is where the academic world separates from the real world: Manufacturers do not make 165Ω resistors, so you have to settle for the closet value that you can actually acquire from sources such as Mouser Electronics.
So, is that it? Well, not quite. Remember, another important specification of a resistor is its power rating, measured in watts. To calculate the power rating of the resistor we have to use Joule’s power law:
P(Watt)=IMAX2×Rlimit=20mA2×220Ω=0.09W
Based on the calculation, then 1/8W resistor will work just fine, though a 1/4W resistor may be easier to find. A resistor of either power rating will work.
A word of caution when powering multiple LEDs. You may be tempted to save on board space or resistor count by using one resistor for many LEDs. Do not do this. LEDs, like most electronic components, are not ideal. Some LEDs may have lower voltage drops then others. This will result in a greater current flowing through them, possibly destroying the LEDs. Always use one resistor for each LED to compensate for the varying forward voltages. If you do need to conserve board space, consider resistor networks (Figure 2), which offer multiple resistors that share one common pin in a single package.
Figure 2: Resistor networks combine multiple resistors in a single package. (Source: Mouser Electronics)
There you have it: Everything you need to know to appropriately size a current-limiting resistor. You will use current-limiting resistors in many applications, not just for powering LEDs. This blog should give you enough of a background to get started building your own LED-powered projects.
To further simplify this process, go to Mouser’s LED Series Resistor Calculator.
Michael Parks, P.E. is the co-founder of Green Shoe Garage, a custom electronics design studio and embedded security research firm located in Western Maryland. He produces the Gears of Resistance Podcast to help raise public awareness of technical and scientific matters. Michael is also a licensed Professional Engineer in the state of Maryland and holds a Master’s degree in systems engineering from Johns Hopkins University.