← Back to Calculators

LED Resistor Calculator

Tired of releasing the magic blue smoke from your LEDs? Whether you're hooking up a basic red LED to a 5V Arduino or a high-brightness blue LED to a 3.3V ESP32, this calculator gives you the exact resistor you need to keep your circuits safe and your lights shining brightly.

e.g., 5V for Arduino, 3.3V for ESP32, 9V for battery
e.g., Red/Yellow/Green = ~2.0V, Blue/White = ~3.2V
in milliamps (mA). 20mA is standard for typical 5mm LEDs.

The Formula: How to Calculate an LED Resistor

The calculation is based on Ohm's Law. You need to drop the excess voltage (Source minus LED voltage) across a resistor to limit the current.

R = (Vs - Vf) / If
  • Vs = Source Voltage (your power supply)
  • Vf = Forward Voltage of the LED (what the LED "eats")
  • If = Forward Current in Amps (Divide mA by 1000. 20mA = 0.02A)

Worked Examples

Example 1: 5V Arduino to a standard Red LED

A typical red LED drops about 2.0V and wants 20mA (0.02A) of current.

  • R = (5V - 2.0V) / 0.02A
  • R = 3.0V / 0.02A
  • R = 150 Ω

Example 2: 3.3V ESP32 to a Blue LED

Blue and White LEDs require a higher forward voltage, usually around 3.2V. They still typically want 20mA.

  • R = (3.3V - 3.2V) / 0.02A
  • R = 0.1V / 0.02A
  • R = 5 Ω (Though using a slightly higher value like 10Ω or 22Ω is safer to account for voltage spikes!)

Mistakes to Avoid (Don't Fry Your Gear!)

  • Forgetting to convert mA to Amps: The math requires Amps. If you type 20 into the formula instead of 0.02, your calculation will be completely wrong.
  • Ignoring Power Dissipation (Watts): Resistors get hot! The calculator above shows power in milliwatts (mW). If it goes above 250mW, a standard 1/4 watt resistor will literally start smoking. You'll need a 1/2W or 1W resistor instead.
  • Wiring LEDs in parallel with one resistor: Never share a single resistor across multiple LEDs wired in parallel. Because of tiny manufacturing differences, one LED will hog all the current and burn out, creating a chain reaction that kills them all. Give every LED its own resistor!

Deepen Your Electronics Knowledge

Want to understand what's actually happening inside these components? Check out our Academy lessons: