Resistor color code calculator
All tools

Choosing the Right Series Resistor for an LED

An LED has almost no built-in current limiting, so a resistor in series decides how much current flows. The formula is one line; choosing sensible numbers to put into it is what this guide is about.

By the Feeed team · · 7 min read

Connect a red LED straight across a 5 V supply and it will flash brightly and then go dark for good, or drag the supply down trying. A resistor in series prevents that. Working out its value takes a single formula, but the inputs, especially forward voltage and target current, deserve more thought than most quick tutorials give them.

Why an LED needs a series resistor

An LED's current does not rise in proportion to voltage the way a resistor's does. Below its forward voltage it barely conducts; a little above it, current climbs steeply. A typical red indicator LED might pass about 1 mA at 1.7 V and 20 mA at around 2.0 V, so a change of a few tenths of a volt is the difference between dim and destroyed. No ordinary supply is precise enough to set LED current by voltage alone.

A series resistor fixes this. The supply voltage is shared between the LED and the resistor, and because the resistor's current is directly proportional to the voltage across it, the current becomes predictable. Small variations in supply voltage or forward voltage now produce small changes in current instead of large ones.

The formula

For one LED or a string of identical LEDs in series:

R = (Vs − n × Vf) / I

  • Vs is the supply voltage, or the high output voltage of the pin driving the LED.
  • n is the number of LEDs in series.
  • Vf is the forward voltage of one LED at the current you want.
  • I is the target current in amps, so 20 mA is 0.020 A.

The top line is simply the voltage left over for the resistor, and dividing it by the current is Ohm's law. If you have the LED's datasheet, read Vf at your chosen current from it. If not, the table below gives realistic starting figures.

Typical forward voltages

LED colorTypical VfNotes
Infrared (850–940 nm)1.2–1.5 VInvisible; check with a phone camera
Red1.8–2.2 VEasiest color to drive from 3.3 V
Orange, yellow2.0–2.2 VSimilar to red
Traditional (yellow-) green2.0–2.2 VThe older, paler green
True green, blue, white2.8–3.4 VLeaves little headroom on 3.3 V

Forward voltage rises slightly with current and falls by roughly 2 mV for every degree Celsius the LED warms up, which is one reason a little resistor headroom is healthy. As for current, many classic 3 mm and 5 mm indicator LEDs are rated for 20 mA continuous, but modern high-efficiency parts are clearly visible at 2 to 5 mA. For a status light on a desk, 5 mA is usually plenty and is much kinder to a microcontroller pin.

Worked examples

Red LED on 5 V at 20 mA

(5 − 2.0) / 0.020 = 150 Ω, which happens to be a standard value. If this LED's real Vf turns out to be 1.9 V, the current is 3.1 / 150 = 20.7 mA; at 2.1 V it is 19.3 mA. The resistor drops 3 V, which is enough headroom to keep the current steady. Its power is 0.020² × 150 = 0.06 W, comfortable for a 1/4 W part. Details for this value are on the 150 Ω resistor page.

150 Ω ±5% resistor: Brown-Green-Brown-Gold

Halve the current and the same calculation gives 300 Ω, so a 330 Ω resistor (9.1 mA) is a good choice. The 220 Ω resistor found in so many kits gives 13.6 mA, and even a 1 kΩ resistor, at 3 mA, leaves a modern LED clearly lit.

White LED from a 3.3 V GPIO pin

Take a white LED with a typical Vf of 3.0 V and a modest 5 mA target: (3.3 − 3.0) / 0.005 = 60 Ω, so 68 Ω. On paper that works. In practice, white LEDs vary from about 2.8 V to 3.4 V. With a 2.9 V part the current is 0.4 / 68 = 5.9 mA; with a 3.2 V part it is 0.1 / 68 = 1.5 mA; with a 3.4 V part the LED barely glows. The pin's own output voltage also sags as it supplies current. With only 0.3 V of headroom, the resistor is no longer setting the current; the LED's own curve is.

There are two clean fixes. Use a red or yellow LED, where (3.3 − 2.0) / 0.005 = 260 Ω becomes a 270 Ω resistor and 4.8 mA. Or run the white LED from 5 V and switch it with an NPN transistor or logic-level MOSFET driven by the pin. At 15 mA, allowing about 0.2 V across the switching transistor, (5 − 3.0 − 0.2) / 0.015 = 120 Ω.

Three LEDs in series on 12 V

Three red LEDs need 3 × 2.0 = 6.0 V, leaving 6 V for the resistor. At 20 mA that is 300 Ω. 300 Ω is an E24 value, but with a typical E12 kit you round up to 330 Ω, giving 6 / 330 = 18.2 mA. The resistor dissipates 6 × 0.0182 = 0.11 W.

330 Ω ±5% resistor: Orange-Orange-Brown-Gold

Three white LEDs are trickier: 3 × 3.1 = 9.3 V leaves only 2.7 V, and a "12 V" system is often not 12 V. A car's electrical system runs at about 14.4 V while the alternator is charging. Design for the highest voltage you expect: (14.4 − 9.3) / 0.020 = 255 Ω, so 270 Ω. At 14.4 V the current is 18.9 mA; at 12.0 V it drops to 10 mA. A twofold brightness change is the price of a simple resistor here, and it is why constant-current drivers exist. Vehicle wiring also carries voltage spikes, so anything permanent in a car needs proper protection as well.

Ready-made tables for every common LED color at 10 mA and 20 mA, with series strings and supply tolerance, are on the pages for 3.3 V, 5 V, 9 V, 12 V and 24 V.

Round up, then check the power

The calculated value is rarely a standard value. Round up to the next one you have, which lowers the current slightly instead of raising it. With a 1.8 V red LED on 5 V at 20 mA, the formula gives 160 Ω. That exists in the E24 series, but with an E12 kit the next value up is 180 Ω. The standard resistor values page lists every series.

Then check the resistor's power with P = I² × R, or simply the voltage across it times the current, and pick a rating at least twice that figure.

CircuitResistorCurrentPower in resistorSuitable rating
5 V, 1 red LED150 Ω20 mA0.06 W1/8 W or 1/4 W
3.3 V, 1 red LED270 Ω4.8 mA0.006 Wany size
12 V, 3 red LEDs330 Ω18.2 mA0.11 W1/4 W
12 V, 1 red LED560 Ω17.9 mA0.18 W1/2 W

The last row shows why a single LED on 12 V is wasteful: the resistor burns five times as much power as the LED. Putting more LEDs in series uses that voltage instead of turning it into heat. The guide to resistor power ratings covers derating and safety margins in more detail.

One resistor per LED in parallel

It is tempting to wire five LEDs in parallel and feed them through one resistor sized for five times the current. It works badly. LEDs from the same bag differ in forward voltage by a tenth of a volt or more, and because the current curve is so steep, the LED with the lowest Vf takes a disproportionate share. That LED runs hotter, its Vf falls further, and it takes still more current. If one LED fails open, the survivors share the full current and are overdriven. Give every LED, or every series string, its own resistor.

Arduino and Raspberry Pi pin limits

A microcontroller pin is a convenient LED driver, within limits. Many MCU pins are rated around 20 mA, with a higher absolute maximum that is not meant for continuous use, and there is usually a lower total limit for all pins on a port or package together. Ten LEDs at 20 mA each can exceed that total even when every pin is individually within spec, so check your board's datasheet before driving many LEDs directly. The output voltage also drops as a pin supplies more current, which a careful calculation should account for.

Raspberry Pi GPIO pins are 3.3 V, are not 5 V tolerant, and are designed for small currents. Keep LEDs on them to a few milliamps and look up the current guidance in the official documentation. For anything brighter, let the pin switch a transistor and power the LED from the supply rail. The LED resistor calculator runs all of these numbers for you, and the Ohm's law calculator is useful for checking voltages and power afterwards.

Calculate your LED resistor →