Sizing an LED resistor
LEDs are current-driven parts. Once the voltage across an LED passes its forward voltage, the current rises very steeply, so connecting one straight to a battery or USB supply usually destroys it within moments. A resistor in series sets the current to a safe value by dropping the voltage the LED does not need.
The formula
R = (Vsupply − n × Vf) ÷ I
- Vsupply is your supply or battery voltage.
- Vf is the LED forward voltage, and n is how many LEDs share the string.
- I is the current you want, in amps (20 mA is 0.02 A).
For a white LED (3.2 V) on 5 V at 20 mA: (5 − 3.2) ÷ 0.02 = 90 Ω. 90 Ω is not a standard value, so round up to the next one, 100 Ω. Rounding up keeps the current slightly below your target (18 mA here) rather than above it.
Resistor power rating
The resistor turns its share of the voltage into heat: P = I² × R. In the example that is about 32 mW, well within a common 1/4 W resistor. Pick a rating of at least twice the calculated dissipation so the part runs cool. When the number gets large, say above 1 W, most of your power is being wasted as heat and a constant-current driver is the better choice.
Typical forward voltages
| LED colour | Typical Vf at 20 mA |
|---|---|
| Infrared | 1.2–1.5 V |
| Red | 1.8–2.2 V |
| Orange, yellow | 2.0–2.2 V |
| Yellow-green (older GaP) | 2.0–2.4 V |
| Green (InGaN), blue, white | 2.8–3.4 V |
| UV | 3.2–3.8 V |
These are typical figures. If you have the datasheet, use its forward voltage at your chosen current.
Several LEDs
LEDs in series share one current, so one resistor serves the whole string. The forward voltages add up, and the total has to stay below the supply with some margin. If less than a volt or so is left for the resistor, small differences in Vf or supply voltage change the current a lot. For LEDs in parallel, give each LED its own resistor. Sharing one resistor between parallel LEDs lets the LED with the lowest Vf hog the current.