Learn
Wiring a Diode to a Raspberry Pi 4B — Blocking Current in One Direction
Wire a 1N4148 or 1N4007 diode in series with an LED and see it block current when reversed — the one real behavior a diode exists to demonstrate, no code required.
Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.
What you’ll need
- Raspberry Pi 4B
- Diode (1N4148 or 1N4007)
- Resistor (~220Ω)
- LED
Step by step
- Drag Raspberry Pi 4B, a Diode, a Resistor, and an LED onto the Canvas.
- Hover over the Diode's two pins to confirm the labels: Anode and Cathode. The darker banded end is always the cathode — current only flows anode → cathode, never the other way.
- Wire the forward direction first: Pi's 3.3V pin → Diode's Anode. Diode's Cathode → the Resistor → the LED's anode (+). LED's cathode (−) → a Pi GND pin.
- Click Start.
- You should see the LED light up immediately — the diode is forward-biased (current flowing anode → cathode), so it conducts and the resistor lets the LED light normally.
- Now reverse the diode without touching anything else: move the wire that was on the Anode over to the Cathode, and the wire that was on the Cathode over to the Anode — so the Pi's 3.3V pin now reaches the Cathode first.
- Click Start again.
What “working correctly” looks like
- Wired the correct way (Pi power → Anode → Cathode → resistor → LED), the LED lights the instant Start is clicked, with no code at all.
- Wired backward (Pi power → Cathode → Anode → resistor → LED), the LED stays off — the diode is now reverse-biased and blocks current, exactly like a real diode would.
If something’s wrong
- LED never lights in either orientation → double-check the LED's own anode/cathode aren't swapped too; two reversed parts in the same circuit can cancel each other out and hide whether the diode itself is working.
- LED lights in BOTH orientations → confirm you actually moved both wire ends when reversing the diode, not just one — the Cathode and Anode need to fully swap positions, not just one wire moving.