Why an LED needs a resistor
An LED drops a nearly fixed voltage, its forward voltage, and above that its current rises very steeply. Without something to limit the current, it overheats and fails. A resistor in series sets the current.
The formula
R = (supply voltage − LED forward voltage) ÷ current
A red LED with a forward voltage of 2.0 V at 20 mA on a 5 V supply needs (5 − 2) ÷ 0.020 = 150 Ω. A white LED at 3.2 V on 12 V needs (12 − 3.2) ÷ 0.020 = 440 Ω; use the next standard value up, 470 Ω.
Typical forward voltages are about 1.8 to 2.2 V for red, yellow and orange, and about 2.8 to 3.4 V for blue, white and most green LEDs. The datasheet gives the exact figure.
Power rating
The resistor turns the extra voltage into heat: P = I² × R. For the 150 Ω example, 0.02² × 150 = 0.06 W, so a common 0.25 W resistor is fine. Choose a rating at least double the calculated power.
Several LEDs
In series, add the forward voltages and use one resistor, as long as the total stays below the supply. In parallel, give each LED its own resistor, because small differences between LEDs make them share current unevenly.
Calculator
The LED Resistor Calculator gives the exact value, the nearest standard value and the power. For other circuits, the Ohm's Law Calculator and the Series and Parallel Calculator do the rest.
Three LEDs in series
Three white LEDs at 3.2 V each on a 12 V supply, at 20 mA: the LEDs drop 9.6 V, leaving 2.4 V for the resistor. R = 2.4 ÷ 0.020 = 120 Ω, and the power in it is 0.02² × 120 = 0.048 W, well inside a 0.25 W part.
A fourth LED would need 12.8 V, more than the supply, so it would not light. Keep the total forward voltage below about 80% of the supply, so the resistor still has something to work with.
Running an LED dimmer
Most indicator LEDs are clearly visible at 5 mA, and modern ones at 1 to 2 mA. At 5 mA on 5 V with a 2.0 V red LED: R = 3 ÷ 0.005 = 600 Ω, so use 620 Ω. That is one fourth the current and heat of 20 mA, which matters in battery devices and in a panel full of indicators.
Common problems
- The LED is dim or dead on 3 V. A blue or white LED needs about 3 V by itself, so there is nothing left for a resistor on two AA cells. Use a boost driver, or a red LED.
- LEDs in parallel without separate resistors. The one with the lowest forward voltage takes most of the current, runs hot and fails first. Give each its own resistor.
- Driving an LED straight from a pin. Microcontroller pins often allow 20 mA at most, and the total across all pins is limited too. Use a transistor for anything brighter.
- The resistor runs hot. Check P = I² × R against the resistor's rating, and pick a part rated at least double.