Raspberry Pi practice problem · LEDs & PWM
Two LEDs, two wires
MediumBudget $4Python · gpiozero
An LED only conducts one way, so two LEDs wired back to back between the same two pins can be lit separately — this is the trick behind bi-colour LEDs.
Wire, each LED with its own 330 Ω resistor:
- GPIO17 → resistor → red LED → GPIO27
- GPIO27 → resistor → green LED → GPIO17
(no connection to GND). Then loop every 1.5 s:
| time | GPIO17 | GPIO27 | result |
|---|---|---|---|
| 0–0.5 s | high | low | red on |
| 0.5–1.0 s | low | high | green on |
| 1.0–1.5 s | high | high | both off |
The "off" phase must use both pins high — no voltage difference, no current.