Which resistor does an LED need, and why
An LED is not a bulb: connect it straight across a battery and it takes whatever current the battery can give, and dies. A resistor in series sets the current. Its value comes from Ohm's law applied to the voltage the LED leaves over: R = (VS − VF) / I. This calculator does that for one LED or a string of them, rounds up to a resistor you can actually buy, shows the real current and brightness you get with it, the heat the resistor must shed and the power rating to choose, and draws the circuit with the LED lit.
How to use the LED resistor calculator
- Enter the supply voltage: 5 V for USB or an Arduino pin, 3.3 V for an ESP32 or Raspberry Pi pin, 9 V or 12 V for batteries and adapters.
- Pick the LED colour to fill in a typical forward voltage, or type the VF from the data sheet (red and yellow about 2 V, green 2–3 V, blue and white about 3.2 V).
- Type the current in milliamps. 20 mA is the usual rating for a 5 mm indicator LED; 5–10 mA is plenty for a status light and kinder to a microcontroller pin.
- Set how many LEDs are in series if there is more than one on the same resistor. The supply must be higher than their forward voltages added up.
- Read the standard resistor to buy, its colour bands and power rating, and the real current. Standard values lists the neighbouring resistors; Calculation writes the maths out; click the resistor or an LED in the drawing for its own figures.
The formula
R = (VS − n × VF) / IF
An LED keeps a nearly fixed voltage across itself, its forward voltage VF, once it conducts; push more current and VF barely rises. So the resistor sees the rest of the supply, VS − VF (times n for n LEDs in series), and Ohm's law gives the resistor that lets the chosen current through. The current, not the voltage, decides the brightness.
Your circuit R = (5 V − 2 V) / 20 mA = 150 Ω → 150 Ω.
Round up to a standard value
Resistors come in the E24 series: 10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91 and their multiples of ten. The calculated value is rarely one of them. Choose the next value up: a slightly larger resistor gives slightly less current, which you will not see; a smaller one pushes the LED past its rating. 5% tolerance is fine for an indicator.
| Supply | LED | Exact | Use | Current |
|---|---|---|---|---|
| 3.3 V | Red (2 V) | 65 Ω | 68 Ω | 19.1 mA |
| 3.3 V | Blue (3.2 V) | 5 Ω | 5.1 Ω | 19.6 mA |
| 5 V | Red (2 V) | 150 Ω | 150 Ω | 20 mA |
| 5 V | Blue or white (3.2 V) | 90 Ω | 91 Ω | 19.8 mA |
| 9 V | Red (2 V) | 350 Ω | 360 Ω | 19.4 mA |
| 12 V | White (3.2 V) | 440 Ω | 470 Ω | 18.7 mA |
The resistor's power rating
PR = (VS − n × VF) × I
Everything the resistor drops turns into heat. At 5 V and 20 mA that is 60 mW, nothing for a ¼ W resistor. At 12 V with one 2 V LED it is 200 mW, which a ¼ W part survives but runs hot; at 24 V it is 440 mW and needs a ½ W or 1 W resistor. The usual rule is a rating of at least twice the heat. Putting more LEDs in series on a high supply is the better fix: the voltage does useful work instead of warming a resistor.
LEDs in series and in parallel
In series (as the drawing shows) the same current flows through every LED, so one resistor serves the whole string; just add the forward voltages. A 12 V supply runs three 3.2 V white LEDs (9.6 V) with 2.4 V left for the resistor, far more efficient than three separate 12 V circuits.
In parallel LEDs must each have their own resistor. Two LEDs on one shared resistor never split the current fairly: tiny differences in VF send most of it through one LED, which heats up, drops its VF further and takes still more. Give every parallel branch its own resistor, calculated for that branch's LED.
Your circuit, step by step
- Left for the resistor: 5 V − 2 V = 3 V.
- Exact resistor: 3 V / 20 mA = 150 Ω; buy 150 Ω (Brown, green, brown, gold), which gives 20 mA, 100% of the target.
- Heat: 3 V × 20 mA = 60 mW → a 1/8 W resistor.
- Power: each LED 40 mW; the whole circuit draws 100 mW, 40% of it in the LED.
Worked example: a red LED on 5 V at 20 mA
The LED keeps about 2 V, so the resistor gets 5 V − 2 V = 3 V. R = 3 V / 20 mA = 150 Ω, which is a standard value (brown, green, brown). The resistor heats by 3 V × 20 mA = 60 mW, fine for a ¼ W part; the LED gets 40 mW. On a 3.3 V board the same LED has only 1.3 V to play with: 1.3 V / 20 mA = 65 Ω, use 68 Ω, and at 10 mA, 130 Ω. On 12 V it would be 10 V / 20 mA = 500 Ω → 510 Ω, but the resistor then burns 200 mW, so a string of three to five LEDs is the better use of 12 V.
Questions
Can I leave the resistor out on 3.3 V with a blue LED?
Risky. A 3.2 V LED on 3.3 V gives about 0.1 V to a resistor, so with no resistor the current depends entirely on the LED's exact VF and the supply's exact voltage, and it can be anything from dim to destructive. Use a small resistor (33–68 Ω) and accept that the brightness will vary from LED to LED.
Does it matter which side of the LED the resistor goes?
No. In a series loop the current is the same everywhere; the resistor limits it from either side. The LED's polarity does matter: the long lead (anode) goes towards the positive supply.
What current does a microcontroller pin allow?
Most pins are rated for 20 mA or so (an ESP32 pin about 12 mA, an Arduino Uno pin 20 mA with 40 mA absolute maximum). Calculate the resistor for 5–10 mA from a pin; a modern LED is bright enough at that, and the chip stays within its total limit when several pins drive LEDs at once.
Why does the calculator round up and not to the nearest value?
Because the nearest value may be below the exact one, and then the current goes above the LED's rating. Brightness loss from rounding up is a few percent and invisible; the parallel resistor calculator can build an in-between value from two resistors if you really need it.