PinLab › Components › LED
anode (+) long legcathode (−) flat side

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

PinWhat it isWhere it connects / why
Anode (+)Longer leg, rounded side of the bodyTo an ESP32 GPIO pin (directly or through the resistor).
Cathode (−)Shorter leg, flat side of the bodyTo 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

Used in projects