LED
light-emitting diode 5 mm
A semiconductor that lights up when current flows through it in the right direction. The most basic output element — it teaches you what a digital output is, PWM, and why you need a resistor.
Open the course →How it works
Current flows only from the anode (+) to the cathode (−). Once the voltage exceeds the "turn-on" threshold (Vf, about 2 V for red), the LED lights. Problem: the LED does not limit the current itself — without a resistor it draws too much and burns out (or damages the ESP32 pin). That is why there is always a series resistor. Calculation: R = (3.3 V − Vf) / I = (3.3 − 2.0) / 0.010 A = 130 Ω → use the standard 220 Ω.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| Anode (+) | Longer leg, rounded side of the body | To an ESP32 GPIO pin (directly or through the resistor). |
| Cathode (−) | Shorter leg, flat side of the body | To GND (through a 220 Ω resistor if the resistor is not on the anode). The resistor can go on either side — it just has to be in series. |
Specifications
Voltage (Vf) red/yellow1.8 – 2.2 V
Voltage (Vf) green/blue/white2.8 – 3.4 V
Current5–20 mA (10 mA is plenty bright)
Resistor for 3.3 V220 Ω (universal), 1 kΩ for dimmer light
Max current20–30 mA
Tips and typical mistakes
- If it does not light, flip it — reversed polarity is the most common mistake. It will not be damaged.
- Blue and white LEDs have little headroom at 3.3 V (Vf ≈ 3 V) — they will be dimmer. That is normal.
- Several LEDs on one pin? No — each pin gives max ~12 mA. Use a transistor or separate pins.