The LED and its resistor is the first circuit most engineers ever build and one of the few they will build for the rest of their careers, on every status indicator, every front panel and every debug pin. It is also a circuit that is routinely done slightly wrong: a resistor pulled from a drawer, a quarter-watt part running hot, a white LED on 3.3 V flickering with the supply. This guide is the reasoning behind the LED resistor calculator.
Why an LED needs something to set its current
An LED is a diode. Its current does not rise in proportion to voltage, as a resistor's does; it rises exponentially. Below a threshold almost nothing flows, and above it a few tenths of a volt more than doubles the current. Connect an LED whose forward voltage is 2.0 V to a 2.0 V supply and it might glow, might be dark, or, if the supply is really 2.2 V, might draw enough current to burn out within seconds. Because the threshold also drifts with temperature and differs from one LED to the next, no fixed voltage can be right.
So the circuit sets the current instead, and lets the LED find its own voltage. The simplest current setter is a resistor in series with a supply well above the LED's voltage: whatever voltage the LED does not take, the resistor takes, and the resistor converts that voltage into a current by Ohm's law.
The formula and what each term means
- Vsupply is the voltage across the LED and resistor together: a regulator output, a battery, a microcontroller pin at its logic level (which for a pin sourcing 20 mA may be well under the nominal 3.3 V or 5 V; check the datasheet's VOH at that current).
- Vf, the forward voltage, is the voltage the LED settles at when passing the intended current. It is set by the semiconductor's band gap, which is why it goes with colour: red and infrared about 1.8–2.2 V, yellow and amber 2.0–2.2 V, green from 2.0 V (old GaP types) to 3.2 V (modern InGaN), blue and white 3.0–3.4 V, UV up to 4 V. Take the datasheet value at your current; the typical figure is given at a test current, usually 20 mA, and is lower at lower currents.
- If is the current you want, not the maximum the LED can take. Indicator LEDs are rated 20–30 mA, but a modern high-efficiency indicator is bright at 2 mA and glaring at 10. Running an indicator at a few milliamps saves power, heat and the eyes of whoever reads the panel.
A red LED at 20 mA from 5 V: (5 − 2.0) ÷ 0.020 = 150 Ω. The same LED from 12 V: 500 Ω. Three white LEDs in series (3 × 3.2 V) from 12 V: (12 − 9.6) ÷ 0.020 = 120 Ω.
Headroom: the voltage the resistor is left with
The resistor's share of the supply, Vsupply − Vf, is the headroom, and it decides how stable the current is. Suppose the LED's Vf is 0.2 V higher than the datasheet said (well within normal spread). With 10 V of headroom the current falls 2 %. With 1 V of headroom it falls 20 %. With 0.3 V, which is what a 3.5 V white LED on a 3.3 V rail would have if it worked at all, the circuit is at the mercy of every variation in supply, temperature and part.
A working rule: keep the headroom above 1 V, or above 20 % of the supply, whichever is larger. Where that is impossible, as with white LEDs on 3.3 V logic, use a higher rail if one exists or a constant-current driver. The calculator warns when the headroom is thin.
There is a cost to generous headroom: the resistor dissipates it. That 500 Ω resistor from 12 V burns 0.2 W to deliver 0.04 W to the LED. For an indicator that is irrelevant; for a string of 50 or a battery product it is not, and the answer is a series string that uses up most of the supply in LEDs (three white LEDs on 12 V, headroom 2.4 V) or a switching driver.
Choosing a real resistor
Resistors come in preferred values, the E-series of IEC 60063: E12 for 10 % tolerance (12 values per decade), E24 for 5 % (24 values), E96 for 1 %. A calculated 500 Ω becomes 470 Ω or 510 Ω. Round up: a slightly larger resistor gives slightly less current, which costs nothing in brightness that the eye can detect and keeps the LED further from its limit. 510 Ω on the 12 V red LED gives 19.6 mA instead of 20.
Then the power rating. Dissipation is headroom × current, or I²R: 10 V × 19.6 mA = 0.196 W. A resistor run at its full rating reaches a surface temperature over 100 °C, which is bad for it, for neighbouring parts and for a hand that touches it, so choose a rating of at least twice the dissipation: here ½ W, not ¼ W. Surface-mount parts are smaller and derate harder; a 0603 chip resistor is typically 0.1 W, a 0805 0.125 W, a 1206 0.25 W, so the 12 V indicator wants a 2512 or a through-hole part, or, more sensibly, a lower current.
Series strings and why parallel is a mistake
LEDs in series share one current, which is exactly what they want; their forward voltages add and the string needs one resistor sized for the total. Three, four or ten LEDs in a string from 12 V or 24 V is the normal way to build a bar of indicators or a light strip. The limits are the supply voltage (the string's Vf total plus headroom must fit under it) and the fact that if one LED fails open the whole string goes dark.
LEDs in parallel behind a single resistor are a mistake that looks fine on the bench and fails in the field. Their forward voltages differ by tenths of a volt, so the one with the lowest Vf takes most of the current, runs hottest, and its Vf falls further as it warms, taking still more. It fails first, then the next. Give every LED, or every series string, its own resistor.
When a resistor is the wrong tool
- Power LEDs (350 mA and up, 1 W and up): the resistor would dissipate as much as the LED, and the thermal drift of a power LED's Vf makes the current wander. Use a constant-current driver, linear for small currents and switching for larger ones.
- Battery supplies with a wide voltage range: a lithium cell swings from 4.2 V to 3.0 V, a 30 % change in headroom for a 2 V LED. A driver holds the current; a resistor cannot.
- Precise or matched brightness: resistor tolerance plus Vf spread gives brightness variation of tens of percent between nominally identical channels. Matched-current LED driver ICs exist for this.
- Dimming: change the resistor and the colour of some LEDs shifts with current. Pulse-width modulation at full current, from a microcontroller pin or a driver's PWM input, dims without colour shift and with a linear-feeling response.
A checklist
- Read Vf from the datasheet at the current you intend to use.
- Pick a current: 2–5 mA for a modern indicator, 10–20 mA if it must be seen in daylight.
- Check the headroom: over 1 V and over 20 % of the supply.
- Calculate R, round up to E24, recalculate the current.
- Calculate dissipation and choose a rating of at least twice it.
- One resistor per string; never LEDs in parallel.
- Check the supply at both extremes (unloaded adapter, flat battery, logic pin under load).
References
- Horowitz, P. and Hill, W., The Art of Electronics, 3rd ed., Cambridge University Press, 2015 — chapter 1, diodes and current limiting
- IEC 60063:2015, Preferred number series for resistors and capacitors
- IEC 60115-1:2020, Fixed resistors for use in electronic equipment — Part 1: Generic specification — rated dissipation and temperature derating
- Schubert, E. F., Light-Emitting Diodes, 3rd ed., 2018 — forward voltage, band gap and temperature dependence