Do I Need a Resistor for My LED?

Short answer: yes. Most LEDs need a resistor to limit current, or they can burn out and damage your pin.

Why the resistor matters

LEDs are current driven. Without a resistor, they draw too much current. That can fry the LED or the microcontroller output.

Quick resistor values

  • 5V boards (Arduino Uno): 220Ω to 330Ω
  • 3.3V boards (ESP32): 100Ω to 220Ω

Safe default

Use 220Ω for 5V and 150Ω for 3.3V. It will be safe and bright enough.

How to calculate it

Use this simple formula:

R = (Vcc - Vled) / I

Example for a red LED on 5V: (5V - 2V) / 0.01A = 300Ω. A 330Ω resistor is perfect.

When you might not need one

  • Some LED modules already include a resistor on the board.
  • Addressable LEDs like WS2812 have built in current control.

If you are unsure, add a resistor anyway. It is cheap protection.

Do not do this

Do not connect a bare LED directly from a pin to ground without a resistor.

Related: What is the difference between digital and analog pins? · Why is my sensor giving random readings? · Why can't I upload code?