Diode
A diode conducts one way and blocks the other. It costs $0.10 and does two everyday jobs on a breadboard: it sets the direction of a current (so a mistake in wiring shows up as "nothing happens" instead of smoke), and it protects a driver transistor from the kick a coil or motor throws back when it switches off — the flyback diode. The 1N4148 is the small signal part; the band printed on its body marks the cathode, the end that must face the more negative side.
Pins
| Pin | What it is | Type |
|---|---|---|
| A | Anode (+) | passive |
| K | Cathode (−, the band) | passive |
| Setting | Type | Range | Default |
|---|---|---|---|
model | enum | 1N4148, 1N4007 | 1N4148 |
Diode("1N4148")— Diode (1N4148) — $0.10- Pins: 2
- Chain ends:
A >> diode >> K - Aliases:
anode→A,cathode→K
A is the anode and K the cathode (the band). Current flows A → K when the anode is about 0.7 V above the cathode, and essentially not at all the other way.
Wiring it in circuit.py
In series with an LED, the diode drops about 0.7 V and shows its direction — flip it and the LED stays dark:
from wiring import *
pi = Pi()
d1 = Diode("1N4148") # band (cathode) toward the LED
r1 = Resistor(330)
led = LED("red")
pi.GPIO17 >> r1 >> d1.anode
d1.cathode >> led.anode
led.cathode >> pi.GNDThe 0.7 V it eats is the point of the exercise: (3.3 − 0.7 − 2.0) ÷ 330 leaves about 2 mA for the LED, so it glows dimly. Swap the diode's ends and the branch goes dark.
Driving it in main.py
from gpiozero import OutputDevice
from time import sleep
power = OutputDevice(17) # lights the LED only when the diode points the right way
while True:
power.on()
sleep(0.5)
power.off()
sleep(0.5)Electrical notes
- Forward drop rises with current: about 0.6 V at a milliamp, 0.7 V at a few, 0.9 V near the 1N4148's 300 mA limit. The simulator solves the Shockley curve, so the drop is a result, not a constant.
- Reverse breakdown (100 V for the 1N4148) is not modelled: past it the simulator still blocks.
- The flyback job: a coil cannot stop its current instantly, so switching one off pushes that current somewhere. A diode across the winding, cathode to the positive rail, gives it a harmless loop to run down in. Without it the voltage spikes until something gives — usually the transistor. See the coil page for the circuit.
- Ratings feed the part's warning checks; the LED is the part with the burn-out setting, so a diode simply warns.
Simulator vs real hardware
- Real diodes are not perfectly one-way (microamps leak backwards) and they have a capacitance that matters at high frequency; neither is modelled.
- The 1N4148's glass body makes it easy to read the band under a lamp — worth doing, because a reversed flyback diode is the classic silent mistake.