Connecting an LED looks simple. Two wires, apply voltage, light appears. Until it doesn't work, or worse: it burns out immediately.

The problem is that an LED has no built-in current limiting. Apply more voltage than it can handle and it draws more and more current — until it fails. That happens in an instant. There's no second chance.

The current-limiting resistor: always, almost always

The solution is a series resistor. It absorbs the voltage difference and limits the current to a safe value.

The calculation: subtract the LED's forward voltage from your supply voltage, then divide by the desired current. A red LED has a forward voltage of roughly 1.8 to 2.2 V. Blue and white are higher, around 3 V. On a 5 V supply with a red LED (2 V) and 10 mA target current: (5 - 2) / 0.01 = 300 Ω. The standard value 330 Ω is fine.

For a simple indicator LED, 5 to 10 mA is more than enough. Brighter isn't always better — and it saves the microcontroller pin. Good choices are the CRCW0805330RFKEA (330 Ω, 1%, SMD 0805) or the CRG0805F10K (10 kΩ) as a pull-up alongside the LED circuit.

Polarity: long leg is positive

An LED only conducts in one direction. The anode (positive) is almost always the long leg on through-hole LEDs; the cathode (negative) is the short leg. The housing also has a flat side at the cathode.

Need a 5 mm red LED for your prototype? The HLMP-EG24-PS000 from Broadcom is a reliable standard through-hole LED with over 20,000 units in stock. For 3 mm green, the HLMP-1503 is a good choice.

Breadboard with coloured LEDs, current-limiting resistors and a 5 volt supply

With SMD LEDs, the markings vary by manufacturer. Always check the datasheet or the marking on the tape.

GPIO pins are not a power supply

With Arduino, ESP32 or Raspberry Pi, an LED is often connected directly to a pin. Do this carefully. A GPIO pin can deliver 8 to 40 mA depending on the platform, but running continuously at the limit shortens the microcontroller's life.

Keep LED current below 10 mA per pin, always use a resistor, and never connect multiple LEDs in parallel on a single pin without individual resistors.

LED strips are a different story

A single LED and an LED strip are not interchangeable. Many strips have on-board resistors per segment, but total current demand can reach tens of amperes on longer strips. Then you need a dedicated power supply, adequately rated wiring, and possibly a MOSFET for switching.

Common mistakes

LED inserted backwards (simply doesn't work, rarely causes damage), no resistor used (LED burns out), drawing too much current from a GPIO pin (microcontroller damaged), and assuming all LED colours have the same forward voltage (white and blue are higher than red and yellow).

When in doubt, start with a higher resistance value. Less bright is better than broken.