What Is a Relay?

Learn how a relay lets a small signal control a larger circuit — safely and at low voltage only.

LESSON COMPASS

What will you use this page for?

Core idea

A relay is an electrically operated switch that uses a small control signal to turn a larger or separate circuit on and off.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Trying to switch mains electricity This is the most dangerous mistake. Some relay boards say "up to 220V," but that does not mean children should control the electricity from a wall socket. Mains electricity is deadly. In these lessons we use only low-voltage sources such as a battery or USB. Trying to power the load…

Next connection

Filtering Sensor Data

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration30–45 min
PrerequisiteWhat Is a Stepper Motor?
ContentStandard lesson · 1,661 words
Last updated

One-sentence summary

A relay is an electrically operated switch that uses a small control signal to turn a larger or separate circuit on and off.

Why does it matter?

A microcontroller such as a micro:bit or an Arduino works with very small currents. The current its pins can supply is enough to light a small LED, but not much more. So how can this tiny board control a circuit it could never power on its own?

This is exactly where a relay helps. A relay keeps two circuits apart: on one side is the small signal from the board, and on the other side is a circuit powered by its own separate supply. The small signal never powers the big circuit directly; it only sends the command "turn on" or "turn off."

You can find this idea everywhere in daily life. A car horn, an air-conditioner fan, automatic watering systems and smart home plugs are all controlled with relay logic. A small button safely manages a much more powerful system.

Important: This lesson is entirely conceptual. Children should never switch mains electricity (the 220 volts from a wall socket) with a relay. Every example here uses only low-voltage educational circuits powered by a battery or USB, and is done with an adult present.

How does a relay work?

A switch, but not turned by hand

You open and close an ordinary light switch with your finger. A relay is also a switch, but a small electric signal opens and closes it instead of a finger.

Inside a classic mechanical relay there is a small electromagnet (a coil) and a metal arm. When current flows through the coil, it becomes a magnet, the magnet pulls the metal arm, and the arm brings two contacts together to close the circuit. When the current stops, the magnet disappears, a spring pushes the arm back, and the circuit opens again.

That is why you often hear a small "click" from a working relay. The click is the moment the arm moves.

Two separate circuits: the control side and the load side

The easiest way to understand a relay is to picture it as two separate zones:

These two sides do not physically touch; the relay keeps them electrically apart. The board only says "turn on now," while the real current flows through the relay in the load circuit.

NO and NC: normally open, normally closed

You will often see two short labels on relay terminals:

For example, if you want an alarm buzzer to stay silent normally and sound only when a sensor is triggered, you use the NO terminal.

The logic of controlling a relay

From a microcontroller's point of view, driving a relay looks as simple as lighting an LED: you set a pin "high" (HIGH) and the relay closes; you set it "low" (LOW) and the relay opens. The difference is that a separately powered circuit sits behind that relay.

Pseudocode

The example below uses a light sensor: when it detects darkness, the relay turns on a separate low-voltage LED circuit.

Start
Read the light level
If the light level is below the threshold
  turn the relay pin ON   (load circuit closes, LED lights up)
Otherwise
  turn the relay pin OFF  (load circuit opens, LED goes off)
Repeat

micro:bit-style example

from microbit import *

while True:
    light = display.read_light_level()
    if light < 50:
        pin0.write_digital(1)   # relay activates: LED circuit closes
    else:
        pin0.write_digital(0)   # relay releases: LED circuit opens
    sleep(200)

Here pin0 does not drive a big load directly; it drives the control input of a relay board. The actual LED circuit on the relay board is powered by its own battery pack. The board only makes the decision; the relay carries the power.

Everyday examples

An automatic night light

Imagine a night light that turns on when a room gets dark and turns off when it brightens. A sensor detects the darkness, the board reads it and tells the relay to "turn on." The lamp is powered from its own separate low-voltage circuit. The board does not power the lamp directly; it only sends the small signal that moves the relay's arm.

A watering reminder

If a soil-moisture sensor measures that the soil has dried out, the board can use a relay to sound a small warning buzzer. The buzzer gets its power from a separate low-voltage supply, not from the board's pin. In this way the board safely "manages" a current it could not carry itself.

Mini practice

For this activity you do not need to solder or wire anything; the goal is to build the logic on paper.

Scenario: A door sensor should light a warning LED when the door opens. The LED circuit is powered by a separate battery pack and controlled through a relay.

  1. Write down which board pin will go to the relay's control input.
  2. Should you use the NO terminal or the NC terminal? Why?
  3. You want the LED to light while the door is open. Write the pseudocode.
  4. State whether the power source that runs the relay and the power source that feeds the LED are the same or separate.

Example pseudocode:

Start
Read the door sensor
If the door is open
  turn the relay pin ON  (NO contact closes, LED lights up)
Otherwise
  turn the relay pin OFF
Repeat

With an adult, you can also try this logic with a real relay board in a low-voltage setup powered only by a battery.

Common mistakes

Trying to switch mains electricity

This is the most dangerous mistake. Some relay boards say "up to 220V," but that does not mean children should control the electricity from a wall socket. Mains electricity is deadly. In these lessons we use only low-voltage sources such as a battery or USB.

Trying to power the load directly from a board pin

A relay feeds a buzzer, motor or lamp from a separate power source, not from the board's pin. If you connect the load straight to the pin, you strain the board and may damage it.

Mixing up NO and NC

If you do not think about whether the circuit should start open or closed, the LED works the opposite way: it goes off when you open the door and lights up when you close it.

Forgetting the common ground (GND) connection

In most setups the board and the control side of the relay board must share a common ground. If this connection is missing, the relay never triggers.

Safety note

Lesson summary

Check questions

  1. In the simplest terms, what does a relay do?
  2. How does the electromagnet inside a relay open and close the circuit?
  3. What is the difference between the control side and the load side?
  4. What is the difference between the NO and NC terminals?
  5. Which kinds of power sources do we use with a relay in these lessons, and which do we never use?

Answers

  1. It uses a small control signal to turn a separate, usually larger, circuit on and off. In other words, it is a switch operated by electricity.
  2. When current flows through the coil, it becomes a magnet that pulls the metal arm, and the arm brings the contacts together (or separates them). When the current stops, a spring pushes the arm back.
  3. The control side receives the board's small signal and drives the coil. The load side is powered by its own low-voltage supply and gets switched on and off. The two are electrically separate.
  4. NO is normally open and closes when the signal arrives; NC is normally closed and opens when the signal arrives.
  5. Only low-voltage sources are used: a battery, USB, micro:bit or Arduino. Mains electricity (the 220 volts from a wall socket) is never used.

Source and verification note

For “What Is a Relay?”, verification focuses on whether the relationship between How does a relay work? and Two separate circuits: the control side and the load side remains consistent across examples. Sensor readings can change with the model, supply voltage and environment. Thresholds in the lessons are therefore examples; a real project should use a measurement table and calibration.

Next lesson

Filtering Sensor Data

Start QuizBack to Sensors and Actuators
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.