MyRoboPath
electronics15 min readUpdated 2026-03-14Beginner

Switches, Relays & Buttons: Mechanical Switching & Coil Isolation

Master electromechanical switching: understand SPST, SPDT, and DPDT switch topologies, relay coil electromagnetic actuation, optical galvanic isolation, and flyback diode snubbers.

MyRoboPath Engineering Lab
Peer-Reviewed Open-Source Hardware & Firmware Guide

Key Engineering Takeaways

  • Poles (P) define how many separate circuits a switch controls; Throws (T) define how many output positions each pole connects to.
  • An electromechanical relay uses a low-power 5V electromagnetic coil to mechanically pull high-voltage/high-current contacts closed.
  • Relays have three contact terminals: COM (Common), NO (Normally Open), and NC (Normally Closed).
  • Never connect a relay coil directly to a microcontroller pin: coils require 70mA+ and produce destructive 100V+ inductive flyback spikes.
  • Solid State Relays (SSRs) and Optocouplers switch loads with light beams (LED + phototransistor), providing 5000V electrical isolation.
Prerequisites
  • Transistors as switches and Diode fundamentals
Required Hardware / Tools
  • 5V Electromechanical Relay Module
  • 2N2222 NPN Transistor
  • 1N4007 Diode
  • SPDT Toggle Switch
  • Breadboard

Switch Configurations: SPST, SPDT, DPDT & Momentary

Mechanical switches physically open or close conductive metal contacts to route electric current: ### Switch Terminology: - **Poles**: The number of independent circuits the switch controls simultaneously. - **Throws**: The number of output contact pathways connected to each pole. ### Common Configurations: 1. **SPST (Single Pole, Single Throw)**: Simple ON/OFF switch with 2 pins (e.g. power switch). 2. **SPDT (Single Pole, Double Throw)**: 3 pins. Routes input (COM) to either Output A or Output B. 3. **DPDT (Double Pole, Double Throw)**: 6 pins. Two isolated SPDT switches linked by a single mechanical toggle (used for H-Bridge motor polarity reversal). 4. **Normally Open (NO) Pushbutton**: Circuit is disconnected until pressed. 5. **Normally Closed (NC) Pushbutton**: Circuit is connected until pressed (used for Emergency Stop buttons).
Switch pole and throw configurations diagram
Figure 1.1: Schematic symbols and internal contact layouts for SPST, SPDT, and DPDT switches.Visual Guide

How Electromechanical Relays Work (NO, NC & COM Contacts)

A **Relay** is an electrically operated mechanical switch. It allows a low-power microcontroller (3.3V / 5mA) to safely turn ON a high-power load (240V AC / 10A motor or solenoid) with complete physical isolation. ### The 3 Output Terminals: - **COM (Common)**: The moving center contact terminal. - **NC (Normally Closed)**: Connected to COM when the relay coil is DE-ENERGIZED (OFF). - **NO (Normally Open)**: Connected to COM when the relay coil is ENERGIZED (ON). When DC current passes through the internal coil, it generates a magnetic field that physically pulls down an iron armature, clicking the contact from NC to NO!
Electromechanical relay internal structure diagram
Figure 1.2: Internal construction of an electromechanical relay showing coil, spring, armature, and contacts.Visual Guide

Transistor Driver Circuits & Flyback Protection Diodes

A standard 5V relay coil draws 70mA - 100mA, exceeding the 20mA safety limit of Arduino and ESP32 GPIO pins. ### The Complete Relay Driver Circuit: 1. **NPN Transistor (2N2222 / BC547)**: Acts as a low-side switch controlling current to the coil. 2. **1 kΩ Base Resistor**: Limits current from the GPIO pin into the transistor base. 3. **Flyback Diode (1N4007)**: Connected in reverse parallel across the coil (+ cathode to VCC, anode to collector). When the coil turns off, the diode absorbs the massive inductive collapse spike, saving the transistor from destruction.
Transistor relay driver circuit schematic
Figure 1.3: Transistor relay driver schematic with flyback snubber diode and microcontroller GPIO input.Visual Guide
Flyback Diode RuleNever drive a relay coil or DC motor with a transistor without a flyback diode. The 100V+ inductive spike will destroy your driving transistor on the very first switch off!

Frequently Asked Questions

What is the difference between an Electromechanical Relay and a Solid State Relay (SSR)?

Electromechanical relays have moving mechanical contacts that make an audible click and can wear out after ~100,000 cycles. Solid State Relays use power semiconductor triacs/MOSFETs with zero moving parts, silent operation, and unlimited switching lifespans.

Tags:#Switches#Relays#Optocouplers#Electromechanical#Flyback Diode#Hardware Isolation