LED resistor calculator

Enter the supply voltage, the LED’s forward voltage and the current you want. You get the exact resistor, the standard (E12) value to buy, and the current that really flows with it.

Exact resistor
—

Resistor to buy (E12, next value up)
—
Current with that resistor
—
Heat in the resistor
—

Results are arithmetic on published formulas, not measurements. Check them on your hardware. Free, no sign-up

Why an LED needs a resistor

An LED is a diode. Below its forward voltage almost no current flows; just above it, the current climbs very steeply with every extra millivolt. Connected straight to a supply, the LED takes as much current as the supply or the pin can give, and the LED, the pin or both burn out.

A resistor in series fixes this. The LED keeps roughly its forward voltage, the resistor takes the rest, and Ohm’s law sets the current: the leftover voltage divided by the resistance.

Choosing the values

Forward voltage (Vf) depends mostly on the colour. Typical values: red about 1.8 to 2.2 V, yellow and orange about 2.0 to 2.2 V, classic yellow-green about 2.1 to 2.2 V, bright (true) green, blue and white about 2.8 to 3.4 V. The LED’s datasheet gives the exact figure at a stated current.

Current: common 3 mm and 5 mm indicator LEDs are rated about 20 mA maximum. Modern LEDs are already bright at 2 to 10 mA, which is also kinder to a microcontroller pin.

Standard value: resistors are sold in fixed series. This calculator rounds up to the next E12 value, so the real current ends up a little under your target, never over.

The formula

R = (Vsupply − Vf) / I
I(real) = (Vsupply − Vf) / R(standard)
P = (Vsupply − Vf)² / R(standard)

Source: Ohm’s law. Standard values: E12 series, IEC 60063.

Worked example

A red LED (forward voltage about 2.0 V) on a 3.3 V pin of an ESP32 or Raspberry Pi Pico, at 10 mA: R = (3.3 − 2.0) V / 0.010 A = 130 Ω. The next E12 value up is 150 Ω, which gives 8.67 mA and about 11.3 mW of heat, so any small 1/4 W resistor is fine.

The same LED on a 5 V Arduino Uno pin: R = (5 − 2.0) V / 0.010 A = 300 Ω, so buy 330 Ω: 9.09 mA and 27.3 mW.

Questions and answers

Why does an LED need a resistor?

Once the voltage passes an LED’s forward voltage, its current rises very steeply, so without something to limit it the LED draws far too much current and fails, and it can damage the pin that drives it. A series resistor takes the extra voltage and sets the current by Ohm’s law.

Does the resistor go before or after the LED?

Either side works. In a series circuit the same current flows through every part, so the resistor can sit between the supply and the LED’s anode (the long leg) or between its cathode (the short leg, flat side) and ground.

Can several LEDs share one resistor?

Not when the LEDs are in parallel: their forward voltages differ slightly, so the LED with the lowest one takes most of the current. Give each LED its own resistor. LEDs in series can share one resistor, as long as the supply is higher than the sum of their forward voltages.

What wattage should the resistor be?

Work out the heat with P = (Vsupply − Vf)² / R and pick a resistor rated for at least twice that. For indicator LEDs this is a few tens of milliwatts, so the common 1/4 W (250 mW) resistor is plenty.

How much current can a microcontroller pin give an LED?

It depends on the chip, so check its datasheet. The ATmega328P on an Arduino Uno allows at most 40 mA per pin (absolute maximum), so 20 mA or less is a sensible target. RP2040 pins on a Raspberry Pi Pico are set to 4 mA drive strength by default (2 to 12 mA can be chosen); ask for more and the pin voltage drops. For bright LEDs or many LEDs, switch them with a transistor.

Can I run a blue or white LED from 3.3 V?

Only just. With a forward voltage around 3 V, only a few tenths of a volt are left for the resistor, so the current depends strongly on the exact LED and its temperature. It is fine for a dim indicator; for steady brightness use 5 V with a transistor, or a constant-current LED driver.

Learn the background

Free lessons of the BoardPilot course that explain the ideas behind this calculator:

Other calculators

See it on a real board

BoardPilot uses these same calculations inside the app, next to a live 3D view of your board, its pins and wires, with guided debugging when something does not work. Try it in your browser, or download it for macOS and Windows.