Basics
Why an LED needs a resistor
An LED is a diode whose brightness is set by current, not voltage. Near its forward voltage (Vf) the current rises exponentially, so connecting an LED straight to a supply means a 0.1 V excess can multiply the current several times and destroy it almost instantly. A series resistor is the simplest current limiter: it absorbs the leftover voltage and holds the current roughly constant. Subtract the LED voltage from the supply, and Ohm's law turns that leftover voltage and your target current into a resistance.
R = (Vs − n × Vf) / If P_R = If² × R Efficiency ≈ (n × Vf) / Vs
Worked examples
- 5 V supply, one red LED (Vf 2.0 V), 10 mA: R = (5 − 2.0) / 0.01 = 300 Ω. 300 Ω is an E24 value, and dissipation is 0.01² × 300 = 30 mW, so an 0603 (1/10 W) chip is plenty.
- 12 V supply, three white LEDs (Vf 3.1 V) in series, 20 mA: R = (12 − 9.3) / 0.02 = 135 Ω. There is no 135 Ω in E24, so the next value up, 150 Ω, gives 18 mA and about 49 mW in the resistor. With a 2× margin an 0603 (100 mW) is borderline; an 0805 (1/8 W) is the comfortable choice.
The calculator recommends the next higher standard value rather than the nearest one, because rounding down pushes the current above target. It still shows the nearest value, so pick that if you want a touch more brightness.
Current
How much current should an LED get?
The datasheet gives an absolute maximum continuous current (often 20–30 mA for small indicator LEDs) and a test current at which brightness and Vf are specified. You rarely need to run at either. Perceived brightness is roughly logarithmic, so halving the current looks much less than half as bright, and modern high-efficiency parts are clearly visible at 1–5 mA. Running well below the maximum also slows lumen depreciation and keeps the junction cooler, which matters in sealed enclosures because the allowed current derates as ambient temperature rises.
Driving an LED from a microcontroller pin
A red LED (Vf ≈ 2.0 V) on a 3.3 V GPIO at 2 mA needs R = (3.3 − 2.0) / 0.002 = 650 Ω; the next E24 value up is 680 Ω, giving about 1.9 mA. Blue, white and true-green LEDs (Vf ≈ 3.0–3.2 V) barely light from 3.3 V, so drive them from 5 V through a small transistor or MOSFET. Wiring the LED from the supply to the pin (active-low, the pin sinks current) is common because many MCUs sink current more strongly than they source it. Either way, check both the per-pin and the total-port current limits in the MCU datasheet.
Comparison
Resistor or constant-current driver?
| Series resistor | Linear CC driver | Switching (buck/boost) driver | |
|---|---|---|---|
| Cost and parts | Lowest — one resistor | Low — one small IC | Higher — IC, inductor, diode |
| Current stability | Depends on headroom and Vf | Good | Good |
| Efficiency | n·Vf / Vs | n·Vf / Vs (excess burned in IC) | Typically 85–95% |
| Best for | Indicators, low current | Strings with modest headroom | Lighting, power LEDs, battery |
Two further details catch people out. First, LEDs tolerate very little reverse voltage — often only about 5 V — so if the supply can be reversed or is AC, add a series or anti-parallel diode. Second, bi-color and RGB LEDs combine dies with different forward voltages (red near 2 V, green and blue near 3 V), so each color needs its own resistor; one shared resistor would make the red die hog the current.
Pitfalls
Common mistakes
- Paralleling LEDs on one resistor: Vf varies slightly between parts, so the LED with the lowest Vf hogs the current. Give each parallel string its own resistor.
- Designing with almost no headroom: a 3.1 V white LED on a 3.3 V rail leaves only 0.2 V across the resistor, so part spread and supply variation swing the current wildly. Check the 'Vf ±0.1 V' current range the tool shows.
- Ignoring MCU pin limits: each GPIO and each port has a maximum current. Check the datasheet and use a transistor if you exceed it.
- Sizing for average current under PWM: size the resistor for the peak (on-state) current.
- Running the resistor at its exact rating: chip ratings are usually specified at 70 °C and derate above it. Choose at least twice the calculated dissipation.
In practice
Tips from KEMI's bench
Indicator LEDs need far less current than most people assume. Modern high-efficiency chip LEDs are clearly visible indoors at 1–5 mA, so habitually running 20 mA just wastes power and dazzles users; on battery products, cutting LED current is the easiest power saving there is. Conversely, for lighting or power LEDs at hundreds of milliamps, or long series strings with little headroom, a constant-current LED driver beats a resistor on both efficiency and stability. Electrically it makes no difference whether the resistor sits on the anode or cathode side, so choose whichever routes more cleanly. If decisions like these are holding up your schematic, KEMI's circuit design service can review the power section with you.
