This is the first circuit almost everybody builds, and it is also where the first component gets destroyed. Both facts come from the same property: an LED does not limit its own current.
Why the resistor is not optional
A resistor obeys Ohm's law — double the voltage and you double the current. An LED does not. Below its forward voltage it passes almost nothing; above it, the current climbs almost vertically for a few tenths of a volt more. There is no comfortable operating point in between.
Connect a red LED straight across 5 V and the supply will push whatever current it can manage through it. The die overheats in a fraction of a second. Sometimes it goes dark immediately; more often it glows very brightly for a moment and then fades over the following minutes, which is why people conclude they were sold a bad LED.
The resistor's job is to take up the difference between the supply and the LED's forward voltage, and to set the current by doing so. It is the part actually in control.
The calculation
R = (Vs - Vf) / If
- Vs — the supply voltage
- Vf — the LED's forward voltage, which depends on its colour
- If — the current you want through it, in amps
A red LED on 5 V at 10 mA. Red drops about 2 V, so the resistor must drop the other 3 V:
R = (5 - 2) / 0.010 = 300 ohms
300 is not a preferred value. Round up to 330 — up, not down, because a larger resistor means less current, and the failure mode of too little current is a slightly dim LED rather than a dead one.
P = (Vs - Vf)² / R = 9 / 330 = 0.027 W
LED resistor calculator
Open on its own pageIt rounds up to a resistor you can buy, then tells you the current you will really get.
Forward voltage by colour
Vf is set by the semiconductor the die is made from, and that is what determines the colour — so colour predicts voltage. These are typical figures for ordinary 5 mm and 3 mm indicator LEDs; the datasheet wins if you have one.
| Colour | Typical Vf | Note |
|---|---|---|
| Infrared | 1.2 - 1.4 V | Remote controls, obstacle sensors |
| Red | 1.8 - 2.2 V | The lowest of the visible colours |
| Orange / Amber | 2.0 - 2.2 V | |
| Yellow | 2.1 - 2.2 V | |
| Green (standard) | 2.0 - 2.4 V | The older, dimmer green |
| Green (bright) | 3.0 - 3.4 V | Modern high-brightness — behaves like blue |
| Blue | 3.0 - 3.4 V | |
| White | 3.0 - 3.4 V | A blue die with a phosphor coating |
Blue, white and bright green will not light properly from a 3 V coin cell, and that surprises people. There is not enough voltage left over for a resistor to do anything with.
How much current do you actually want?
The textbook answer is 20 mA, and the textbook is describing the maximum a standard LED will take continuously, not a target. Modern LEDs are far brighter than the parts that number was written for.
- 2 - 5 mA is plenty for an indicator on a board that sits indoors. It will still be clearly lit.
- 10 mA is a comfortable general-purpose figure, and the one to use if you are unsure.
- 20 mA is the usual maximum for a 5 mm LED, and worth it only when the thing must be readable in daylight.
Ready-made answers
| Supply | Red / Yellow (2 V) | Blue / White / Bright green (3.2 V) |
|---|---|---|
| 3.3 V | 150 ohms | Marginal — use 10 ohms to 33 ohms, or a boost |
| 5 V | 330 ohms | 220 ohms |
| 9 V | 680 ohms | 680 ohms |
| 12 V | 1k | 1k |
| 24 V | 2k2 | 2k2 (check the resistor's power rating) |
At 24 V the resistor drops 22 V and dissipates about 0.22 W, so a quarter-watt part is running at its limit. Fit a half-watt one.
Which lead is which
An LED is a diode and only works one way round. Fitted backwards it simply does not light — no harm done at these voltages, and this is worth knowing because a dead-looking LED is usually a reversed one.
- The longer lead is the anode, the positive side. Long lead, long word.
- The flat spot on the rim marks the cathode, the negative side. This one survives having the leads trimmed.
- Inside the package, the larger metal cup is the cathode. Hold it up to the light if the flat has worn away.
Four mistakes that cost components
- 1
Two LEDs in parallel, sharing one resistor
They never share equally. The one with the slightly lower forward voltage takes most of the current, runs hotter, and its Vf falls further as it warms — so it takes even more. One LED ends up bright and short-lived, the other dim. Give each LED its own resistor.
- 2
LEDs in series without checking the supply
Series is fine and efficient — the same current does two jobs — but the forward voltages add. Three white LEDs need 9.6 V before a resistor gets a look in, so they will not run from 5 V at all.
- 3
Driving too many from one microcontroller
An Arduino Uno pin is rated at 20 mA continuous, 40 mA absolute maximum, and the whole chip is limited to about 200 mA total. Eight LEDs at 20 mA is 160 mA through one ground pin. Use a transistor or a driver IC once you are past two or three.
- 4
Forgetting that the pin voltage is not the supply
A 3.3 V board drives its pins to 3.3 V, not 5 V. Calculate with the voltage the pin actually produces, or the LED will be dimmer than you expected — and a blue LED may not light at all.