relays
what is a relay? an electrically controlled switch: energize the coil and the contacts move. great for isolating logic from higher voltages/currents.
driver circuit (logic → relay)
- use a transistor/MOSFET to drive the coil; microcontroller pins alone can’t.
- flyback diode across the coil (stripe to +) to catch the spike.
- pick coil voltage to match your rail (5/12 V) and contacts rated above your load.
contact types
- SPST / SPDT / DPDT — “NO” = normally open, “NC” = normally closed.
- keep mains far from logic; respect creepage/clearance.