LESSONElectronics Basics · Part 9EP.38 · 24 s

The RELAY: 5 V switches 230 V

// WHAT YOU WILL LEARN

A 5 V coil becomes a magnet and pulls the arm (COM: NC → NO) to switch a separate 230 V circuit; a transistor drives the 71 mA coil from an Arduino pin, and a flyback diode across the coil eats the turn-off spike.

// LESSON NOTES

5 volts from an Arduino switching a 230 V lamp? That's a RELAY ⚡ (the lesson we promised!)

1️⃣ INSIDE: a coil wound on an iron core. Power the coil and it becomes a MAGNET. It pulls a metal arm down → CLICK. The arm (COM) leaves NC and touches NO, and the 230 V circuit closes. Cut the power and a spring pulls it back.

2️⃣ THE CIRCUIT: a 5 V relay coil needs about 71 mA (≈ 70 Ω), but an Uno pin gives only 20 mA. So D7 → 1 kΩ → a 2N2222 transistor (4.3 mA into the base) switches the coil.

3️⃣ TWO WORLDS: the 230 V lamp only touches the relay's contacts. No wire goes from the mains side to your Arduino.

4️⃣ ALWAYS ADD A DIODE: when the coil turns off it kicks back a big voltage spike that can kill the transistor. A diode (1N4007) across the coil, band to +5 V, eats it (clamped to about 5.7 V).

⚠️ 230 V can kill. Use a ready, insulated relay module (most have the transistor + diode built in) and let an adult/electrician do the mains wiring. AC and the spike are shown slowed down.

Read the voiceover (transcript)
  1. Five volts... switching two-thirty volts?!
  2. Inside a relay? A coil! Power it, it becomes a magnet, and pulls the arm. Click!
  3. A pin can't power the coil, so a transistor does! And the two-thirty volt side never touches your Arduino.
  4. Always add this diode! It eats the turn-off spike.
  5. Small signal. big switch!
  6. Next: the MOSFET! Follow for lesson ten!

Related lessons