Why an LED needs a resistor
An LED has an almost fixed forward voltage (Vf). Above it, current rises very steeply, so the LED must be fed through something that limits current. For indicator LEDs the simplest option is a series resistor that drops the extra voltage.
Worked examples
Red LED (Vf ≈ 2.0 V) at 20 mA on 5 V: (5 − 2) ÷ 0.020 = 150 Ω, which is a standard E12 value. The resistor dissipates 0.02² × 150 = 0.06 W, so a common 1/8 W or 1/4 W part is fine.
Three white LEDs (3.2 V each) in series on 12 V: (12 − 9.6) ÷ 0.020 = 120 Ω, wasting only 48 mW. One white LED alone on 12 V needs 440 Ω (use 470 Ω) and wastes about 0.16 W: putting LEDs in series is much more efficient.
Rules of thumb
- Always round up to the next standard value: slightly less current, never more.
- Choose a resistor rated at least 2× the power it dissipates.
- Do not wire LEDs in parallel on one resistor: give each string its own resistor.
- Arduino and ESP32 pins should stay well below their limits: about 20 mA per pin on an Uno, much less on many 3.3 V boards.
Frequently asked questions
What resistor do I need for an LED on 5V?
For a red LED at 20 mA, 150 Ω. For blue or white (Vf ≈ 3.2 V) at 20 mA, 90 Ω exact, so use 100 Ω.
Can I use a higher resistor value?
Yes. A higher value means less current and a dimmer, cooler LED. Modern LEDs are often bright enough at 5–10 mA.
What happens without a resistor?
The current is limited only by the supply and wiring, so the LED usually overheats and fails within seconds or minutes.