If you connect an LED directly to a supply with no resistor, it lights up bright for an instant and then burns out. An LED is a device whose current rises sharply once the voltage exceeds a certain value (the forward voltage), so a resistor to limit the current is essential. This article explains, in order, how to calculate the resistance, choose a standard value, and check heat and brightness. Use the LED resistor calculator, which does the calculation once you enter the values, along with it.
Why an LED needs a resistor
An LED is a kind of diode. Almost no current flows before it reaches the forward voltage (Vf), and above that voltage, even a tiny increase in voltage makes the current rise greatly. If the supply voltage is only slightly higher than Vf and there is nothing to limit the current, the LED goes far beyond its allowed current and burns out. So you put a resistor in series with the LED to let the resistor take up the leftover voltage.
The formula
R = (supply voltage - LED forward voltage) / target current
The voltage across the resistor is supply voltage - Vf, and Ohm's law (R = V / I) is applied so that the current becomes the target value.
| LED color | Vf (approx.) |
|---|---|
| Red, orange, yellow | about 1.8–2.2 V |
| Standard green | about 2.0–2.4 V |
| Blue, white, high-brightness green | about 2.8–3.4 V |
The exact value is in the product's datasheet. It differs between manufacturers even for the same color.
Worked examples
Example 1. 5 V supply, red LED, 10 mA R = (5 - 2) / 0.01 = 300Ω. 300 Ω is among the E24 standard values, so use it as is.
Example 2. 3.3 V supply, green LED (Vf 2.2 V), 5 mA R = (3.3 - 2.2) / 0.005 = 220Ω. At 3.3 V, the voltage across the resistor is small (1.1 V), so the current is sensitive to variation in Vf. The current changes a lot even with a different LED, so allow for differences in brightness.
Example 3. 12 V supply, white LED (Vf 3.2 V), 15 mA R = (12 - 3.2) / 0.015 ≈ 587Ω. In E12 you pick 680 Ω (current about 12.9 mA), and in E24, 620 Ω (about 14.2 mA). It is safer to pick the value larger than the calculated one.
Round the standard value up
If the calculated value is not exactly a standard value, pick the larger of the nearby values. A bigger resistor only lowers the current a little and makes it slightly dimmer, while a smaller one goes over the target current. What the standard values are was explained in Reading Resistors.
Checking the resistor's heat
The heat the resistor gives off is P = I² × R or (supply voltage - Vf) × I. Example 1 is 0.01² × 300 = 0.03W (30mW), so a 1/4 W (250 mW) resistor is enough. If the current gets larger or the supply voltage is high, check the rating. The calculator tells you a recommended rating with a 2× margin.
Brightness and current
- A regular indicator LED looks bright enough in a room even at about 2 to 10 mA.
- 20 mA is around the continuous rating of a 5 mm LED, so we recommend staying at or below 10 to 15 mA to leave some room.
- Doubling the current does not look twice as bright to the human eye. It also dims over time and its life can shorten, so run only as much as you need.
- To change brightness, change the resistance or use PWM (switching on and off quickly).
When using several
- In parallel: give each LED its own resistor. If several LEDs share one resistor in parallel, current crowds into the LED with slightly different characteristics, so one burns out first or the brightness differs.
- In series: if the sum of all the Vf values is well below the supply voltage, you can connect several in one line, and only one resistor is needed. In that case
R = (supply voltage - sum of all Vf) / current. The current is the same through every LED.
Common mistakes
| Mistake | Result | Prevention |
|---|---|---|
| Leaving out the resistor | The LED burns out | Always use a series resistor |
| Reversed polarity | Does not light (usually not damaged) | Long lead is +, flat side is − |
| Blue or white LED on 3.3 V | Dim or does not light | Raise the supply voltage or pick an LED with lower Vf |
| Exceeding a microcontroller pin's current | Pin or chip damaged | Check the pin's allowed current in the datasheet, use a transistor if needed |
Checking in Patterndo
In the Patterndo editor, you can place an LED and a resistor and run the simulation to check the current through the LED and whether it lights. To follow along from the start, see Getting Started with Patterndo: Build an LED Circuit.
Summary
The LED resistor is found with (supply voltage − Vf) ÷ target current, round the standard value up, and check the resistor's heat. When connecting in parallel, giving each LED its own resistor is safer. To switch a bigger load next, see Transistor Switch Circuits.