Component guide · Beginner · 3 min read
LEDs Explained
Polarity, Forward Voltage and Resistor Values
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
An LED (light-emitting diode) lights when current flows from its longer leg (anode, +) to its shorter leg (cathode, -). It needs a series resistor to limit current: R = (supply voltage - LED forward voltage) / current. A red LED on 5 V at 15 mA needs about 200 Ω, so use 220 Ω. White and blue LEDs drop about 3 V, red about 2 V.
Key specs at a glance
- Polarity
- Long leg = anode (+), short leg / flat edge = cathode (-)
- Typical current
- 5 mm LED: 10 to 20 mA (20 mA max for most)
- Forward voltage
- Red/yellow 1.8 to 2.2 V; green 2 to 3.2 V; blue/white 2.8 to 3.3 V
- Resistor formula
- R = (Vsupply - Vf) / I
- Dimming
- PWM from a microcontroller pin
Which leg of an LED is positive?
The longer leg is the anode (+). The shorter leg is the cathode (-), and the LED's rim has a flat edge on the cathode side. Inside a clear LED, the larger metal piece is usually the cathode. If an LED does not light, try reversing it; a brief reverse connection at 5 V with a resistor will not damage it.
LED resistor values for common supplies
Using R = (Vsupply - Vf) / I, rounded up to standard values:
| Supply | Red (2.0 V) at 15 mA | Green (3.0 V) at 15 mA | Blue/white (3.1 V) at 15 mA |
|---|---|---|---|
| 3.3 V | 100 Ω | 22 Ω (or run at 10 mA with 33 Ω) | 22 Ω |
| 5 V | 220 Ω | 150 Ω | 150 Ω |
| 9 V | 470 Ω | 470 Ω | 470 Ω |
| 12 V | 680 Ω | 620 Ω | 680 Ω |
- 3.3 V
- Red (2.0 V) at 15 mA:
- 100 Ω
- Green (3.0 V) at 15 mA:
- 22 Ω (or run at 10 mA with 33 Ω)
- Blue/white (3.1 V) at 15 mA:
- 22 Ω
- 5 V
- Red (2.0 V) at 15 mA:
- 220 Ω
- Green (3.0 V) at 15 mA:
- 150 Ω
- Blue/white (3.1 V) at 15 mA:
- 150 Ω
- 9 V
- Red (2.0 V) at 15 mA:
- 470 Ω
- Green (3.0 V) at 15 mA:
- 470 Ω
- Blue/white (3.1 V) at 15 mA:
- 470 Ω
- 12 V
- Red (2.0 V) at 15 mA:
- 680 Ω
- Green (3.0 V) at 15 mA:
- 620 Ω
- Blue/white (3.1 V) at 15 mA:
- 680 Ω
Driving LEDs from microcontroller pins
- Arduino Uno R3: up to 20 mA per pin is fine.
- Arduino Uno R4, ESP32, Pico: keep each pin to about 8 to 12 mA. Use 330 Ω to 1 kΩ for indicator LEDs; modern LEDs are bright even at 2 to 5 mA.
- For many LEDs or high-power LEDs, switch them with a transistor or MOSFET, or use addressable LEDs.
Dimming an LED with PWM
Microcontrollers dim LEDs by switching them on and off hundreds of times a second (PWM). The duty cycle sets brightness.
const int LED = 9; // a PWM pin (~)
void setup() { pinMode(LED, OUTPUT); }
void loop() {
for (int b = 0; b <= 255; b++) { analogWrite(LED, b); delay(5); }
for (int b = 255; b >= 0; b--) { analogWrite(LED, b); delay(5); }
}Types of LEDs
| Type | What it is | Notes |
|---|---|---|
| 3 mm / 5 mm indicator | Standard through-hole LED | 10 to 20 mA, needs a resistor |
| RGB (common cathode or anode) | Three LEDs in one package | Needs one resistor per colour |
| Addressable (WS2812B) | RGB LED with built-in controller | One data pin for many LEDs |
| 1 W / 3 W power LED | High-brightness emitter | Needs a constant-current driver and heatsink |
| IR LED | Infrared emitter | Remote controls, obstacle sensors |
- 3 mm / 5 mm indicator
- What it is:
- Standard through-hole LED
- Notes:
- 10 to 20 mA, needs a resistor
- RGB (common cathode or anode)
- What it is:
- Three LEDs in one package
- Notes:
- Needs one resistor per colour
- Addressable (WS2812B)
- What it is:
- RGB LED with built-in controller
- Notes:
- One data pin for many LEDs
- 1 W / 3 W power LED
- What it is:
- High-brightness emitter
- Notes:
- Needs a constant-current driver and heatsink
- IR LED
- What it is:
- Infrared emitter
- Notes:
- Remote controls, obstacle sensors
Try it: LED resistor calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Connecting an LED without a resistor; it burns out or damages the pin.
- Sharing one resistor between LEDs in parallel; one LED hogs the current.
- Running high-power LEDs from a resistor and a battery instead of a constant-current driver.
- Wiring a common-anode RGB LED as common-cathode; the colours invert or nothing lights.
- Exceeding the current limit of ESP32 or Pico pins with bright LEDs.
Frequently asked questions
What resistor should I use for an LED on 5 V?
220 Ω for red, yellow and orange LEDs, and 150 Ω for green, blue and white, giving about 15 mA. Use 330 Ω to 1 kΩ if you only need an indicator.
Can I connect an LED directly to 3.3 V?
Not safely without a resistor, even though the voltage is close to the LED's forward voltage. Small changes cause large current changes. Use 68 to 100 Ω for red or 22 to 33 Ω for blue/white.
How do I know if an LED is burnt out?
Use the diode test setting on a multimeter: a working LED glows faintly and shows its forward voltage in one direction only.
Can I run several LEDs in series?
Yes, if the supply is higher than their total forward voltage. Three red LEDs (6 V total) on 12 V at 15 mA need (12 - 6) / 0.015 = 400 Ω, so use 390 or 470 Ω.
Why does my LED flicker on camera?
PWM dimming switches the LED on and off; a camera can pick this up. Raise the PWM frequency or use a constant-current dimming driver.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 367 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



