LED series resistor: the value, and the current you get
Compute the resistor from headroom, then find why one part number gives a 2:1 current spread on 3.3 V, what an MCU pin really delivers, and when to stop.
The equation takes one line. Subtract the LED’s forward voltage from the supply, and divide what is left by the current you want:
For one red LED at 20 mA on a 5 V rail with V that is , and the nearest E24 value at or above it is 150 Ω. The LED resistor calculator does this, and the rest of this article is about the part the equation does not tell you: the current you actually get is not the current you designed for, and how far off it is depends almost entirely on the numerator.
That numerator — , the headroom — is the whole story. A real part number publishes a forward-voltage range, not a value. Würth’s WL-SMCW red 0603 (150060RS75000) specifies between 2.0 V and 2.4 V at 20 mA. Fit one 150 Ω resistor and the current across a reel of those parts runs from 17.3 mA to 20.0 mA. Move the same 20 mA design to 3.3 V — which means refitting 56 Ω — and the same 0.4 V bin now spreads it from 16.1 mA to 23.2 mA; stack the supply and resistor tolerances on top and it is 13 mA to 26 mA. The bin did not change and the resistor was re-chosen for the rail. What changed is the headroom the bin is divided into.
The load line, and why the bin is a current spread
An LED is a diode, so its current-voltage curve is exponential and steep. Near the datasheet test current that steepness is what makes the constant- model useful: the LED holds its voltage and the resistor sets the current. The model’s weakness is not the curvature — it is that the curve’s position is a manufacturing outcome.
Plot the resistor’s load line, running from on the voltage axis down to on the current axis, and mark the two forward voltages the datasheet guarantees. Where the load line crosses each is a current, and the difference between them is what a single reel will hand you:
V_F min 2.0 V: I = (5.0 − 2.0) / 150 = 20.0 mA
V_F max 2.4 V: I = (5.0 − 2.4) / 150 = 17.3 mA
Headroom is the design, everything else is arithmetic
Differentiate the current with respect to the forward voltage and the result is as blunt as it looks:
The resistance cancels. A ±0.2 V bin costs ±7 % of the current on a 5 V rail with one red LED, ±18 % on 3.3 V, and ±2 % on 12 V — and the resistor’s own tolerance does not appear in the expression at all. Buying 0.1 % resistors for an LED that sits on 1.1 V of headroom is spending money in the wrong place: the bin contributes ±18 %, a 1 % resistor contributes 1 %, and the 0.1 % part buys back a tenth of that one per cent.
The practical rule that falls out of it: keep the headroom at least ten times the half-width of the bin if the current matters to better than 10 %. For this red LED that is 2 V, which a 5 V rail comfortably provides and a 3.3 V rail does not.
Blue and white LEDs do not run from 3.3 V
The same datasheet family makes the point sharply. The WL-SMCW blue 1206 (150120BS75000) specifies from 3.2 V to 3.5 V at 20 mA. A nominal 3.3 V rail with a ±5 % tolerance falls to 3.135 V — below the minimum of that range, never mind the maximum. There is no resistor value that fixes this, because the problem is not the resistor. The LED is not dark: the datasheet’s own forward-current curve shows the typical part passing roughly 13 mA at 3.135 V with no resistor at all. The problem is that the current is then set entirely by where that part’s curve happens to fall — a bottom-of-bin part passes more, a top-of-bin part far less — and the resistor, with no headroom to divide, no longer sets anything.
This is why blue, white and UV indicators on 3.3 V boards either sit on the 5 V rail, run from a boost, or are accepted as dim and inconsistent. Anything in the InGaN chemistries — blue, true green, white, UV — lands in the 2.8 V to 3.8 V range and needs a rail above it with room to spare. The red, orange, yellow and yellowish-green AlInGaP and GaP parts sit near 2 V and are the ones that work on 3.3 V.
The worst case, with every tolerance stacked
A design is not finished at the nominal. Stack a ±5 % supply, the published range, a 1 % resistor and the E24 value actually fitted, all pushed the same way, and the same 20 mA intent lands very differently depending on the rail:
rail R fitted nominal worst case spread
3.3 V 56 Ω 19.6 mA 13.0 – 26.4 mA 2.03 : 1
5 V 150 Ω 18.7 mA 15.5 – 21.9 mA 1.41 : 1
9 V 360 Ω 18.9 mA 16.9 – 20.9 mA 1.24 : 1
12 V 510 Ω 19.2 mA 17.5 – 21.0 mA 1.20 : 1
For an indicator, 1.41:1 is invisible and 2.03:1 is merely noticeable across a row of boards. For anything measured — an optical sensor’s emitter, a backlight matched to a second panel — even 1.2:1 is a problem, and that is the point at which the resistor stops being the right circuit.
Note also what the 3.3 V row does at the top end: 26.4 mA against a part rated 30 mA continuous. One more adverse tolerance and the design is outside the datasheet.
The resistor is a heater
Whatever headroom buys in current stability, it costs in power. The resistor dissipates and the LED consumes , so the fraction of the supply’s power that becomes light-adjacent falls as the rail rises:
5 V: 56 mW in the resistor, 44 mW in the LED — 44 % to the LED
12 V: 196 mW in the resistor, 44 mW in the LED — 18 % to the LED
At 5 V and 20 mA a 0603 resistor is comfortable. At 12 V, 196 mW is past what an 0603 is usually rated for and well past a derated one; that resistor is now a component with a package decision attached, and its self-heating changes its own value. The voltage divider calculator has the same power arithmetic in it for the same reason.
Driving it straight from a microcontroller pin
The most common version of this circuit puts the supply end of the resistor on a GPIO. That works, and it introduces a resistance that is not on the schematic.
The ATmega328P datasheet (DS40002061B) guarantees an output high voltage of 4.2 V minimum while sourcing 20 mA from a 5 V supply at 85 °C, and an output low voltage of 0.9 V maximum while sinking the same. Read as a source impedance those are 40 Ω and 45 Ω. Put 40 Ω in series with the 150 Ω you fitted and the current falls from 18.7 mA to 14.7 mA — 21 % gone, into a part of the circuit that does not appear in the equation.
Three limits govern how many of these a part can drive, and the datasheet is explicit that they are separate:
DC Current per I/O Pin … 40.0mA DC Current VCC and GND Pins … 200.0mA
and, in the notes to the DC characteristics, the one that actually gets hit. For a pin that sources the LED current, as in this circuit:
The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
and for the other common wiring — resistor to the 5 V rail, pin pulled low to sink the current — the same note gives a smaller figure:
The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100mA.
Those are per-port-group budgets, and the groups are smaller than they look: ADC6 and ADC7 are analog inputs with no output driver, and RESET is the reset pin, so the sourcing group is eleven usable outputs. Eight indicators at 18.7 mA each is 149 mA — the whole 150 mA budget, with every individual pin comfortably inside its own 40 mA rating and the total still under the 200 mA supply-pin figure. Sink-wired, the six port-C pins alone are at 112 mA against a 100 mA limit. The constraint that fails is the one nobody looks up.
The practical answer is not a bigger pin. Modern LEDs at 2 to 5 mA are perfectly visible indicators — the red part above is specified at 120 mcd minimum at 20 mA, which is bright enough to be unpleasant to look at directly — and at 3 mA the pin’s own drop becomes negligible again.
Dimming: PWM is the only knob a resistor leaves you
With a fixed resistor the current is fixed, so the only remaining variable is time. PWM holds the peak at the design point and varies the duty cycle; the average current, the average power in the resistor, and the perceived brightness all scale with duty.
Two constraints set the frequency, and TI’s SLVA451 (Step-Down LED Driver With Dimming) states both while recommending about 100 Hz:
It must be kept low enough such that the turnon and turnoff delays of the TPS62150 do not significantly affect the dimming linearity. It also must be high enough to keep the LED flicker from being noticeable to the human eye.
The upper constraint is about the driver, not the LED; with a plain resistor and a GPIO the delays are nanoseconds and the frequency can be anything above the flicker threshold. A few hundred hertz is a safe floor, and higher is better if the LED will ever be seen in peripheral vision or through a moving camera shutter.
The alternative — analog dimming, reducing the current itself — is not available through a fixed resistor, and it is worse anyway for anything colour-critical: reducing an LED’s current shifts its forward voltage, its efficiency and, in phosphor-converted white parts, its colour point. PWM changes only how long the LED spends at the operating point it was designed for.
The derating nobody applies
Both Würth datasheets carry a derating curve on page 4 — forward current against ambient temperature — and it is not the front-page number. The 30 mA continuous rating holds flat from 0 °C to 50 °C. Above 50 °C the allowed current falls on a straight line, reaching about 14 mA at 85 °C, the top of the part’s own operating range, where the curve cuts off. Both parts share the same curve. Read at the points a designer cares about, the rating is 30 mA at 50 °C, about 28 mA at 55 °C, about 21 mA at 70 °C and about 14 mA at 85 °C.
The datasheets give no thermal resistance, but the power rating and the junction limit imply one, and it is worth computing to see what it means. The red 0603 is rated 72 mW at 25 °C ambient with a 95 °C junction limit, so:
which is an enormous thermal resistance, and entirely believable for a chip that size on two small pads — the same θJA-belongs-to-the-test-board problem that larger packages have, at a scale where it cannot be engineered away. The published 72 mW is exactly , and the blue part’s 105 mW is exactly : the current rating and the power rating are the same statement at 25 °C.
Applied as a straight line from that 25 °C point, a single 972 °C/W would allow 17 mA at 55 °C and only 4.3 mA at 85 °C — about three times less than the vendor’s curve at the top of the range, and well below it at 55 °C, where the vendor still allows 28 mA. So the one-number model is a conservative estimate, not the derating; the vendor’s curve is the rating, and it is not a single-θJA line at all. Either way the direction is the same.
An indicator inside a sealed enclosure next to a regulator is not at 25 °C, and above 50 °C it is no longer a 30 mA part. That is one more argument for driving indicators at a few milliamps rather than at the number on the datasheet’s front page: at 3 mA the derating never arrives.
Current is not brightness
Even with the current held exactly, two LEDs of the same part number are not equally bright. The red 0603’s luminous intensity is specified from 120 to 250 mcd at 20 mA, and the blue 1206’s from 90 to 145 mcd — 2.08:1 and 1.61:1 respectively, at a single test current.
No resistor tolerance touches that. If a row of indicators has to look matched, the answer is a part sold in intensity bins, a per-channel PWM trim, or accepting the variation; it is never a tighter resistor. And it means the 2:1 current spread of the 3.3 V design above is, in visual terms, roughly the same size as the spread the part has anyway.
Two things a resistor cannot do
Share. Two LEDs in parallel on one resistor do not split the current evenly. The lower- part takes more of it, heats up, drops further and takes more still. How much more depends on the slope of the LED’s I-V curve near the operating point — a number these datasheets do not publish, which is itself the argument: a circuit whose current split depends on an unpublished parameter is a circuit that should not be built. One resistor per LED, or one per series string.
Hold a current against a moving supply. The resistor’s current follows one-for-one above the forward voltage, so it amplifies supply variation rather than rejecting it. On a single lithium cell falling from 4.2 V to 3.0 V, the 150 Ω design delivers 13.3 mA down to 5.3 mA — a 2.5:1 change in current, on a battery that is behaving entirely normally.
That is what a constant-current driver buys, and SLVA451 states the reason in one sentence:
Regulating the LED with a constant current for constant brightness is desired, rather than constant voltage regulation.
When to stop using a resistor
The decision is not about elegance. Four thresholds, in the order they usually arrive:
- Headroom under about 2 V, or under ten times the bin’s half-width. Below that the current spread is set by binning and there is nothing you can do about it with passive parts.
- Above roughly 50 mA, where the resistor’s dissipation stops being an 0603-sized problem and the LED’s own shift with temperature starts to matter.
- Battery supplies, where the rail moves over the discharge curve and the brightness moves with it.
- Anything measured rather than looked at — an optical sensor’s emitter, a matched backlight, a calibrated indicator.
Everything else is a resistor, and choosing it is one subtraction and one division. Work the value and the worst-case band out in the LED resistor calculator, which stacks the supply, and resistor tolerances the wrong way and reports the current range rather than the nominal, then check the headroom against Fig 3 before ordering the reel.