What is an RGB LED?
An RGB LED is three LEDs — red, green, and blue — sharing one plastic dome. Your eye can't see them as separate points, so their light adds together. Drive each one at a different brightness and you can mix essentially any color: 256 levels × 3 channels ≈ 16.7 million combinations.
Your Kit's RGB LED: Common Cathode
RGB LEDs come in two flavors, and the code for one is inverted for the other:
- Common cathode (yours): all three LEDs share one GND leg. More PWM = brighter.
- Common anode: all three share one 5V leg. Logic inverts — more PWM = dimmer (use
255 − value).
Pin Configuration
Four legs, and the longest leg is the shared cathode (GND):
| Leg | Function | Mission wiring (Day 8) | |-----|----------|------------------------| | 1 | Red | Pin 11 (~PWM) via resistor | | 2 (longest) | GND | GND | | 3 | Green | Pin 10 (~PWM) via resistor | | 4 | Blue | Pin 9 (~PWM) via resistor |
All three color pins must be PWM pins (~ marked: 3, 5, 6, 9, 10, 11) or you only get 8 crude colors instead of millions.
Why Each Color Needs Its Own Resistor
It's tempting to save parts and put one resistor on the shared GND leg. Don't. Red drops ~2V but green and blue drop ~3V — share a resistor and the red channel hogs the current, skewing every mixed color toward orange. One resistor per color leg (220–330Ω — the Day 14 build uses 330Ω) keeps the channels honest.
Color Mixing
analogWrite() each channel 0–255:
| Red | Green | Blue | Result | |-----|-------|------|--------| | 255 | 0 | 0 | Red | | 0 | 255 | 0 | Green | | 0 | 0 | 255 | Blue | | 255 | 255 | 0 | Yellow | | 255 | 0 | 255 | Magenta | | 0 | 255 | 255 | Cyan | | 255 | 255 | 255 | White | | 255 | 128 | 0 | Orange |
Two things worth knowing about how it looks:
- Brightness isn't linear. The step from 0 → 50 looks huge; 200 → 255 looks nearly identical. Your eye compresses bright light.
- "White" is approximate. The three dies aren't perfectly matched, so 255/255/255 often looks slightly blue or pink. Trim the strongest channel down until it looks right.
Where You'll Use It
| Mission | What it does | |---------|--------------| | Day 8 | First color mixing — mood lighting for the lander | | Day 9 | Smarter code for the same circuit | | Day 14 | Security panel status light: color = system state |
Using color as status (green = OK, yellow = warning, red = alarm) is one of the most useful UI tricks in electronics — Day 14 is a taste of how real control panels work.
Common Mistakes
- One color never lights: that channel's leg is on a wrong pin or its resistor connection is loose
- All colors inverted (red when you asked for cyan): you have common-anode code on a common-cathode part — don't subtract from 255
- Colors look washed out / skewed: shared single resistor instead of one per leg
- Only primary colors work: a color pin is on a non-PWM pin, so it can only be full-on or off