Guide

How to calculate a resistor for an LED

Calculate a limiting resistor for one or more LEDs, choose a commercial value and check tolerance and power.

by Tools in a Tab · Published on · Reviewed on

Short answer

An LED needs current limiting. For a low-power indicator, the simplest method is to place a resistor in series so it drops the voltage left over between the supply and the LED.

The ideal formula is:

R = (Vs - n × Vf) ÷ I

Vs is the supply voltage, Vf is the forward drop of each LED, n is the number of LEDs in series and I is the desired current in amperes. The calculation does not end there: you must then choose a standard value and check tolerance and power dissipation.

Complete example: an LED with a 5 V supply

Let’s assume:

  • Supply: 5 V.
  • LED forward voltage: 2 V.
  • Target current: 20 mA, which is 0.020 A.
  • One LED per branch.

We apply the formula:

R = (5 V - 2 V) ÷ 0.020 A
R = 3 V ÷ 0.020 A
R = 150 Ω

The ideal value is 150 Ω. If we use an E24 resistor with a tolerance of ±5% and we want to avoid exceeding 20 mA at the low end of the tolerance, a conservative choice is 160 Ω.

Nominal current = 3 V ÷ 160 Ω = 18.75 mA
Minimum resistance = 160 Ω × 0.95 = 152 Ω
Maximum current with tolerance = 3 V ÷ 152 Ω ≈ 19.74 mA

The LED resistor calculator reproduces this example and also recommends a minimum standard power rating.

Step 1: Get Vf from the datasheet

Forward voltage is not a fixed number defined solely by color. The datasheet usually gives typical and maximum values at a specific current and temperature. It may also show how Vf changes with current and temperature.

For a first estimate, use the data for your intended operating current. For a real design, check the limits of both the supply and Vf: the highest current normally occurs with the highest supply voltage and the lowest LED forward voltage.

Step 2: Check that there is voltage left for the resistor

The following condition must hold:

Vs > n × Vf

If the sum of the LED drops equals or exceeds the supply, the formula produces a zero or negative resistor value. That does not mean you should omit the resistor; it means the circuit lacks enough voltage headroom to limit current this way.

Step 3: Convert Milliamperes to Amperes

Ohm’s law uses amperes:

20 mA = 0.020 A
5 mA = 0.005 A

Forgetting this conversion changes the result by a factor of a thousand. It is also worth checking whether you really need the maximum rated current. Many modern LEDs provide enough brightness well below 20 mA.

Step 4: Choose a standard resistor value

The ideal value may not exist in the available series. Moving up to the next value reduces current; moving down increases it. For a simple limiter, it is usually safer not to choose a resistor value below the calculated value.

The E12 and E24 series distribute normalized values throughout each decade. For example, E24 includes 150 Ω and 160 Ω. IEC 60063 defines the series of preferred numbers used for resistors and other components.

Tolerance also matters. A 150 Ω ±5% resistor can measure 142.5 Ω, which would raise the example current to about 21.05 mA if the other values did not change. Choosing 160 Ω keeps that tolerance limit below 20 mA in this isolated check.

Step 5: Calculate the power

The power converted to heat in the resistor can be calculated in several ways:

P = Vresistor × I
P = I² × R
P = Vresistor² ÷ R

With 3 V and 160 Ω:

P = 3² ÷ 160 = 0.05625 W

A 1/8 W (0.125 W) resistor is rated at more than twice that nominal dissipation. Even so, its power rating does not guarantee a particular temperature: check the manufacturer’s derating curve, ambient temperature and mounting guidance.

Several LEDs in series

On the same branch, the drops are added and all the LEDs conduct the same current:

R = (Vs - Vf1 - Vf2 - ...) ÷ I

With 12 V, three 2 V and 20 mA LEDs:

R = (12 - 3 × 2) ÷ 0.020 = 300 Ω

The resistor dissipates 6 V × 0.020 A = 0.12 W. A 1/4 W component offers more headroom than a 1/8 W one under those nominal conditions.

LEDs in parallel: one resistor per branch

Avoid connecting several LEDs directly in parallel behind a single resistor. Small differences in Vf can cause uneven current sharing. Use one resistor per branch and calculate each branch for its target current.

The Texas Instruments report on LEDs in parallel analyzes the distribution of current and the compromise between balancing and dissipation.

Check worst cases

For a simple prototype, check at least:

  1. maximum supply with minimum Vf and minimum resistance: maximum current;
  2. minimum supply with maximum Vf and maximum resistance: minimum current;
  3. maximum power dissipated by the resistor;
  4. total current that must be delivered by the source or a GPIO pin;
  5. temperature and component derating.

A microcontroller adds its own per-pin, per-port and device-wide limits. Check its datasheet; the calculator does not know the output voltage drop under load or the current the pin can safely supply.

Common errors

  • Choosing Vf from a generic color table instead of the datasheet.
  • Enter 20 as amperes instead of 0.020 A.
  • Forgetting to add the voltage drops of LEDs in series.
  • Sharing a single resistor between parallel branches.
  • Choosing a lower standard value without recalculating current.
  • Ignoring tolerance, maximum supply voltage, minimum Vf or power.
  • Using a resistor instead of a suitable driver for a power LED.

Method limits

A resistor is suitable for simple indicators when the supply and load are well bounded. It does not maintain constant current across large changes, can waste power and does not solve the thermal-management needs of a power LED. In those cases, use a constant-current driver designed and verified for the application.

Tools in a Tab performs the calculation locally and does not replace the datasheet or electrical validation of the circuit. Use the result as a starting point and measure the prototype under safe conditions.