Skip to content
GEEKnodes

Electronics

LED Resistor Calculator (with Formula and Examples)

Find the right resistor for an LED from the supply voltage, color and current. With the formula, standard E12 values, power rating and Arduino and 12 V examples.

An LED doesn’t limit the current flowing through it on its own: if you connect it straight to a power source, it will try to draw as much as it can and burn out in seconds. That’s why it always comes with a series resistor. This calculator tells you which value you need, which one to buy and what power rating it should have.

Calculator

Exact resistance
—
Standard value (E12)
—
Resistor power rating
—

Pick the color to fill in a typical forward voltage, or type in the one from your LED’s datasheet, which is always more accurate.

The formula

The resistor has to “eat up” the excess voltage between the power source and the LED, letting through exactly the current you want. That’s Ohm’s law:

Series circuit with a 5 V source, a resistor and an LED, with the current and forward voltage marked.
The resistor absorbs the voltage the LED doesn’t need and limits the current in the circuit.
R = (Vfuente − Vf × n) / I
  • Vfuente: the supply voltage (5 V from an Arduino or USB, 3.3 V from an ESP32, 12 V from a power supply…).
  • Vf: the LED’s forward voltage, which depends mainly on its color.
  • n: the number of LEDs connected in series.
  • I: the current in amps (20 mA = 0.02 A).

And the power the resistor dissipates:

P = I² × R

Typical forward voltage by color

ColorTypical VfTypical current (5 mm LED)
Infrared1.2 – 1.5 V20 – 50 mA
Red1.8 – 2.2 V20 mA
Orange / yellow2.0 – 2.2 V20 mA
Green (classic)2.0 – 2.4 V20 mA
Bright green, blue, white2.8 – 3.4 V20 mA

These are ballpark values. If you have the manufacturer’s datasheet, use its figures.

Worked examples

One red LED on an Arduino pin (5 V)

R = (5 − 2) / 0.02 = 150 Ω. The nearest standard value at or above that is 150 Ω, and it dissipates 0.02² × 150 = 60 mW, so a 1/4 W resistor is more than enough.

In practice, Arduino projects usually use 220 Ω or 330 Ω: the LED is almost as bright at 10–15 mA and the microcontroller pin has more headroom (the ATmega328P allows 40 mA per pin as an absolute maximum, but staying at or below 20 mA is recommended).

One white LED on an ESP32 (3.3 V)

R = (3.3 − 3.2) / 0.02 = 5 Ω. The margin here is so small that any variation in Vf changes the current a lot. It’s better to lower the current to around 5–10 mA with 22–47 Ω, or to power the LED from 5 V and switch it with a transistor.

Three white LEDs in series at 12 V

R = (12 − 3 × 3.2) / 0.02 = (12 − 9.6) / 0.02 = 120 Ω, with 48 mW of power. Putting the LEDs in series makes better use of the voltage and wastes less energy in the resistor than giving each LED its own.

Three 3.2 V LEDs and a resistor connected in series to a 12 V source.
In series, the forward voltages of the three LEDs add up to 9.6 V.

Why round up

Resistors are made in standard series (E12, E24…). If your calculation gives 136 Ω, that resistor doesn’t exist, and you have to choose between 120 Ω and 150 Ω. Always pick the higher value: with 150 Ω a little less current flows (the LED looks practically as bright), while with 120 Ω more current than planned would flow.

Common mistakes

Comparison between two parallel branches with one resistor per LED and two LEDs sharing a single resistor.
Each parallel branch needs its own resistor to share the current properly.
  • One resistor for several LEDs in parallel: they don’t share the current evenly, because each LED has a slightly different Vf, and the one with the lowest takes more current and eventually burns out. Use one resistor per branch.
  • LED backwards: the anode (long leg) goes to positive and the cathode (short leg, flat side of the package) to negative. A backwards LED simply won’t light up, and at low voltages it won’t be damaged.
  • Forgetting about power with strips or 24 V supplies: at higher voltages, the resistor can dissipate more than 1/4 W and get very hot. The calculator suggests a power rating with some margin.
  • Power LEDs (1 W, 3 W…): these don’t use a resistor; they use a constant-current driver.

More electronics guides

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor