How to Calculate the Resistor for an LED — A resistor for an LED is not a guess. Three numbers — supply, forward voltage and desired current — are enough to work it out and check that the part.

Calculations

How to Calculate the Resistor for an LED

How to Calculate the Resistor for an LED — A resistor for an LED is not a guess. Three numbers — supply, forward voltage and desired current — are enough to work it out and check that the part.

A resistor for an LED is not a guess. Three numbers — supply, forward voltage and desired current — are enough to work it out and check that the part will survive.

22 November 20268 min read
A selection of resistors, LEDs and a breadboard laid out for an LED current-limiting calculation
The resistor is chosen from the supply, the LED forward voltage and the current you want.

Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →

Build it for real

To build this project for real, get the parts from hobidevre.com → hobidevre.com →

More build guides: hobidevre.com/blog

Why an LED needs a resistor

An LED is a current-driven device. Once its forward voltage is reached, its current rises steeply with only a small further increase in voltage. A fixed-voltage supply connected straight to an LED therefore has no natural way to limit that current. The resistor is not there to make the LED work; it is there to stop the LED from taking more current than it can handle.

This also explains why LED brightness is set by current rather than by voltage. A larger series resistance means less current and a dimmer LED. A smaller one means more current, more light and more heat, until the component is damaged.

The three numbers you need

First, the supply voltage. A 5 V Arduino pin outputs close to 5 V when high; a 3.3 V board outputs close to 3.3 V. Second, the LED forward voltage, written Vf. A red LED is often around 2 V, while blue and white LEDs are usually higher. If you do not have the datasheet, a rough value is enough for a first estimate, and measuring the actual current afterwards is better than trusting the estimate.

Third, the target current. Ordinary 5 mm indicator LEDs are commonly run at a modest fraction of their maximum rating; you do not need to drive one at its limit. Choosing 10 to 20 mA for a typical indicator is a sensible starting point, and a dimmer LED is almost always preferable to a stressed one.

Ohm’s law step by step

The resistor must drop the voltage that the LED does not use. If the supply is Vs and the LED drops Vf, the resistor sees Vs minus Vf. Ohm’s law says resistance equals voltage divided by current, so the formula is R = (Vs − Vf) ÷ I. Current must be in amperes, not milliamperes: 20 mA is 0.020 A.

Write the three numbers on paper before calculating. This prevents the most common slip, which is dividing by 20 instead of 0.020 and getting a resistance a thousand times too small.

R = (Vs - Vf) / I

Vs = supply voltage (V)
Vf = LED forward voltage (V)
I  = desired current (A)

A worked 5 V example

Take a 5 V pin, a red LED with Vf near 2 V and a target of 20 mA. The resistor must drop 5 − 2 = 3 V. Dividing 3 V by 0.020 A gives 150 ohm. That is a valid value and will place the LED near the chosen current.

If you only have a 220 ohm resistor, the current becomes (5 − 2) ÷ 220, roughly 14 mA. The LED will be slightly dimmer but perfectly usable. This is worth remembering: a higher resistor value is generally safe, while a much lower one is not.

Choosing a standard value

Resistors are made in preferred values rather than every possible number. When your calculation lands between two values, pick the next one up if you are unsure. The small loss in brightness is not noticeable in most indicator applications, and the extra margin protects both the LED and the output pin.

If the calculated resistance is very low, stop and reconsider. A result of a few tens of ohms usually means the LED Vf is close to the supply, or that the target current is too ambitious. In that case a lower supply or a different LED is a better answer than an unusually small resistor.

Check the power rating

The resistor turns the dropped voltage into heat. Power is current multiplied by the voltage across the resistor, or I²R if you prefer. In the 220 ohm example, about 14 mA flows and roughly 3 V is dropped, so the resistor dissipates around 0.04 W. A common quarter-watt resistor is comfortably above that.

The check matters when currents are larger or supplies are higher. Always compare the calculated dissipation with the rating printed in the component documentation, and leave headroom rather than running a part at its limit.

When the supply is 3.3 V

Repeat the same calculation with the new supply. With 3.3 V and a 2 V red LED, the resistor must drop 1.3 V. At 10 mA that is 130 ohm; at 20 mA it is 65 ohm. Notice that a resistor designed for 5 V is not automatically right for 3.3 V, and that a high-forward-voltage LED may leave very little voltage for the resistor at all.

If the supply is barely above Vf, the current becomes sensitive to small changes in LED voltage. In that situation, a lower target current and a measured result are more reliable than an optimistic calculation.

Get the parts

Resistor assortments and LEDs are available from hobidevre.com if you want to build and measure the examples above.

Frequently asked questions

Can several LEDs share one resistor?

It is possible but not recommended. Small differences between LEDs lead to unequal currents. Give each LED its own resistor for predictable brightness.

What happens if I choose a much larger resistor?

The LED draws less current and looks dimmer. A modest increase is harmless; an extremely large value may make it invisible.

Does PWM remove the need for a resistor?

No. During each on-pulse the full supply appears across the LED and resistor, so the resistor still limits peak current.

Related reading

Practise in the browser

Open the same layout in the simulator and follow the steps. Sign in to save your work.