LEDs
light-emitting diodes are directional. they like a series resistor; they dislike reverse polarity.
quick start: 5 V → resistor → LED → ground. start with
220 Ω
.
how to wire
- anode (+): the long leg. connect to + through a resistor.
- cathode (−): the short leg / flat edge on the package. connect to ground.
choose the resistor
use ohm’s law: R = (Vsupply − Vf) / I
color | typical Vf | I (nice brightness) | 5 V example |
---|---|---|---|
red | ~2.0 V | 10 mA | (5 − 2)/0.01 = 300 Ω → use 330 Ω |
green | ~2.1 V | 10 mA | ~290 Ω → 330 Ω |
blue/white | ~3.0 V | 10 mA | ~200 Ω → 220 Ω |
PWM dimming
on arduino, use analogWrite(pin, value)
(0–255). keep the series resistor.
don’t forget
- for higher currents (strips, 1W LEDs), use a constant-current driver or a transistor with proper resistor and heat sinking.
- never put an LED straight across a battery without a resistor.