What is an LED?
A Light Emitting Diode (LED) is a semiconductor that emits light when current flows through it. The "diode" part matters as much as the "light" part: a diode is a one-way valve for electricity. Current only flows from the anode (+) to the cathode (−). Hook it up backwards and nothing happens — no light, no damage at kit voltages, just a dark LED.
How It Works
Inside the plastic dome are two tiny regions of semiconductor crystal. When current flows forward, electrons fall into "holes" on the other side of the junction, and each fall releases a little packet of energy as a photon — light. The color comes from the crystal's chemistry, not the plastic: the energy of that fall is fixed by the material, and that energy is the color. That's why you can't turn a red LED blue by painting it.
Which Leg Is Which
Three ways to identify the polarity:
| Clue | Anode (+) | Cathode (−) | |------|-----------|-------------| | Leg length | Longer | Shorter | | Rim of the dome | Round all the way | Small flat spot | | Inside the dome | Smaller post | Larger "anvil" (usually) |
If the legs have been trimmed, the flat spot on the rim is your most reliable clue.
Forward Voltage: Every Color Is Different
An LED doesn't share voltage politely like a resistor does. It "drops" a roughly fixed voltage and passes almost nothing below it — then current climbs steeply above it:
| Color | Typical forward voltage | |-------|------------------------| | Red | 1.8–2.2V | | Yellow | 2.0–2.2V | | Green | 2.0–3.0V | | Blue / White | 3.0–3.3V |
That steep current climb is exactly why the next section exists.
Always Use a Resistor
An LED has almost no resistance of its own once it turns on. Connect it straight to 5V and current rises until the LED burns out — often instantly, sometimes with a tiny pop.
Resistor calculation: R = (V_supply − V_forward) / I_desired
For a red LED on the HERO board's 5V:
R = (5V − 2V) / 0.02A = 150Ω minimum
Your kit's 220Ω resistors give about 14mA — comfortably bright, comfortably safe. Bigger values are always safe, just dimmer: swap in a 10kΩ and the LED still lights, faintly.
Brightness Control with PWM
digitalWrite() gives you on or off. For anything in between, use analogWrite(pin, 0–255) on a PWM pin (marked ~: pins 3, 5, 6, 9, 10, 11). PWM doesn't actually lower the voltage — it switches the LED on and off hundreds of times per second, and your eye averages the flicker into brightness. analogWrite(pin, 64) = on 25% of the time = looks like a quarter brightness.
On a non-PWM pin (2, 4, 7, 8, 12, 13), analogWrite just snaps to full on or full off.
Where You'll Use It
| Mission | What the LED does | |---------|-------------------| | Day 2 | Your first circuit — the lander's cabin light on pin 12 | | Day 3 | The DIP switch becomes its light switch | | Day 4 | Three LEDs: cabin, storage, and cockpit lighting on pins 10–12 |
There's also an LED soldered to pin 13 on the HERO board itself — great for testing code with zero wiring.
Key Specifications
- Max continuous current: 20mA (10–15mA is plenty bright)
- Forward voltage: 1.8–3.3V depending on color
- Lifespan: tens of thousands of hours — you will not wear one out
Common Mistakes
- Backwards LED: no light? Flip it around first — it's the #1 cause
- No resistor: works for a moment, then never again
- Forgot
pinMode(pin, OUTPUT): the pin can't source enough current in input mode — LED stays dim or dark - Dimming on a non-~ pin:
analogWriteonly fades on PWM pins