Electricity/LEDs/An LED and its resistor

An LED and its resistor

An LED does not have a resistance. It has a voltage it insists on, and it will take whatever current is left over to get it — which is why the resistor beside it is not a suggestion and why a blue LED refuses to light on 3.3 V.

Change the colour, the supply and the resistor. Two settings here destroy the LED and one makes it impossible to light at all.

Pick the resistor
R = (Vs − Vf) ÷ I
5 V
220 Ω
2 V
LED colourdrops 2 V
Supply5 V
Series resistor220 Ω
Current
13.6 mA
Headroom
3.0 V
Heat in the resistor
0.041 W
Bright and safe. 13.6 mA, comfortably inside the LED's rating and inside the ~20 mA a GPIO pin will source.

Why it needs a resistor at all

A resistor obeys Ohm's law: double the voltage and you double the current. A diode does not. Below its forward voltage it conducts almost nothing; above it, current rises almost vertically. There is no operating point where it politely limits itself — a tenth of a volt too much is several times the current.

So you do not set the LED's voltage. You set the current, with a resistor in series, and let the LED take the voltage it wants.

Sizing it, in three numbers

R = (supply − forward voltage) ÷ current. For a red LED on 5 V at 15 mA: (5 − 2) ÷ 0.015 = 200 Ω, so fit the 220 Ω in your kit.

Your turn
blue · 3.2 V · 20 mA

A blue LED needs 3.2 V and likes 20 mA. You are driving it from a 5 V pin. Which resistor?

Pick one and find out. There is a formula, but the interesting part is how wide the right answer is. Two of these three work.

Forward voltage depends almost entirely on colour, because it depends on the chemistry that makes that colour:

ColourForward voltageOn a 3.3 V pin
Red~2.0 V1.3 V of headroom, fine
Yellow~2.1 Vworks
Green~2.2 Vworks
Blue / white~3.1 Vonly 0.2 V left — dim and unpredictable

That last row is the one that wastes an evening. A white LED on a 3.3 V board is barely on, and the fix is not a smaller resistor — it is a 5 V supply and a transistor, or a driver chip. Drop to 3 V in the figure above and it does not light at all: there is no resistor value that adds voltage you never had.

Current, and what the pin can give

20 mA is the classic rating and modern LEDs are visible at a tenth of that. An ESP32 pin can source about 20 mA comfortably, with 40 mA the absolute maximum, and that is per pin with a total budget across the chip — eight LEDs at 20 mA is 160 mA out of one package and it will not end well.

If you want more than one or two LEDs bright, drive them from the supply through a transistor and use the pin only to switch it.

The rules of thumb worth keeping

  • 220 Ω on 5 V, 100 Ω on 3.3 V. Right for a red or green indicator every time, and inside the rating.
  • Too big is safe, too small is fatal. If you are unsure, go up. A dim LED tells you the circuit works; a dead one tells you nothing.
  • One resistor per LED, never one shared between two in parallel.

Edit this page — content/fundamentals/electricity/an-led-and-its-resistor.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Fundamentals on the forum