An LED connected straight to a battery or a microcontroller pin will draw as much current as it can — and quickly burn out (or damage the pin). A single resistor in series fixes that by setting the current.
The formula
Note: R = (Vs − Vf) ÷ I
Written plainly:
- Supply voltage (Vs) — what you're powering it from, e.g. 5 V or 3.3 V
- Forward voltage (Vf) — the voltage the LED itself drops, from its datasheet
- Current (I) — how bright you want it; most small indicator LEDs are happy at 5–20 mA
Resistance = (Vs − Vf) ÷ I, with the current in amps (15 mA = 0.015 A).
Typical forward voltages
Always check the datasheet, but these are good starting points for standard 3 mm / 5 mm LEDs:
| LED colour | Typical forward voltage |
|---|---|
| Red | 1.8 – 2.2 V |
| Yellow / orange | 2.0 – 2.2 V |
| Green (standard) | 2.0 – 2.2 V |
| Blue, white, bright green | 2.8 – 3.3 V |
Example 1: red LED on 5 V
- Vs = 5 V, Vf = 2.0 V, I = 15 mA
- R = (5 − 2.0) ÷ 0.015 = 200 Ω
200 Ω isn't a common stock value, so pick the next value up: 220 Ω. That gives (5 − 2.0) ÷ 220 ≈ 13.6 mA — slightly less current, slightly dimmer, and a little kinder to the LED.
Example 2: white LED on 3.3 V
- Vs = 3.3 V, Vf = 3.0 V, I = 10 mA
- R = (3.3 − 3.0) ÷ 0.010 = 30 Ω
With only 0.3 V left across the resistor, small differences in Vf between LEDs make a big difference to the current. It still works, but brightness will vary from LED to LED. If you can, run white and blue LEDs from 5 V instead (R = (5 − 3.0) ÷ 0.010 = 200 Ω → use 220 Ω).
Check the power rating
The resistor turns the extra voltage into heat. Power is P = I² × R:
- Example 1: 0.0136² × 220 ≈ 0.04 W
A standard ¼ W (0.25 W) resistor handles that with lots of room to spare. As a rule of thumb, keep the resistor's power below half of its rating.
Tip: Driving an LED from a microcontroller pin? Stay within the pin's current limit — check the datasheet; many are comfortable around 10–20 mA per pin. Higher currents or many LEDs need a transistor or LED driver.
Quick picks
| Supply | LED | Good starting resistor |
|---|---|---|
| 5 V | Red / yellow / green | 220 Ω – 330 Ω |
| 5 V | Blue / white | 150 Ω – 220 Ω |
| 3.3 V | Red / yellow / green | 68 Ω – 100 Ω |
| 12 V | Red | 680 Ω – 1 kΩ (check power) |
Get the parts
Carbon film ¼ W resistors are perfect for LEDs. Find them by value — search 220 or 330 — or browse resistors. Not sure how to read the ones you have? See our resistor colour code guide.
