← Back to blogBuilding a Computer from Relays · Part 1 of 15

How a Relay Works: The Click That Built Modern Computing

Explore how an electromechanical relay uses a coil, armature, and contacts—and how relay networks helped connect telegraphy, Boolean logic, and early computing.

Matthias KellerMatthias Keller
7 min read
Chalkboard feature illustration for “How a Relay Works: The Click That Built Modern Computing”

Right now, as you read this, transistors inside your device are switching electrical signals with no macroscopic moving parts. Some important early digital machines performed comparable logical switching with electromechanical relays—and those relays made a sharp, audible click.

A relay is a switch operated by electricity. It was not the only precursor to electronic computing, but it provides an unusually visible route from physical contacts to logic gates, arithmetic, and memory.

This is the first stop in a hands-on series we’re calling Building a Computer from Relays. It’s deeply inspired by Charles Petzold’s masterpiece CODE: The Hidden Language of Computer Hardware and Software — but instead of just reading about these circuits, you’ll toggle them live in your browser as we go. Think of it as CODE, made playable.

Let’s start at the very bottom: a single relay.

The problem that invented the relay

Our story opens in the 1830s, decades before anyone dreamed of a computer, with a very practical headache: how do you send a signal down a really long wire?

An electric telegraph sent current through a line to operate an electromagnet at the far end. Wire resistance, leakage, and the sensitivity of the receiving apparatus limited the distance and reliability of a direct circuit. A sufficiently weak received current could no longer operate the mechanism dependably.

One solution was beautifully simple: let the received signal operate a contact that connected a fresh local source. Joseph Henry’s work on strong electromagnets and successive electromagnetic circuits contributed to this development, alongside the work of other telegraph inventors and instrument makers.

That switch was the relay. The name says exactly what it does: it relays the message, like a runner handing off a baton. A tired, faint current arrives, trips a switch, and a brand-new full-strength current carries on. Telegraph operators could now chain relays down the line and span a continent.

Nobody in 1840 was thinking about logic or computers. They just wanted their dots and dashes to reach the next town. But hidden inside that practical little device was an idea that would eventually run the world: a switch controlled by electricity instead of by a human finger. Hold onto that — it’s the whole trick.

How a relay actually works, piece by piece

A relay looks like magic the first time you see one snap to life, but it’s pure first-principles physics. There are just three moving ideas.

1. The electromagnet (the coil). Wind a coil of wire around an iron core and run current through it, and you get a temporary magnet. Current on → magnetic. Current off → not magnetic. This is the relay’s “muscle,” and it’s controlled entirely by electricity.

2. The armature (the lever). Hovering just above the electromagnet sits a small iron lever, held back by a spring. When the coil energizes, its magnetic pull overcomes the spring and yanks the armature down. Cut the current and the spring snaps it right back. That snap is the click you hear.

3. The contacts (the switch). The armature carries a metal contact. As it moves, that contact either bridges or breaks a connection in a second, completely separate circuit. One wire’s current decides whether another wire’s current can flow.

Put them in sequence and the whole device reads like a tiny machine:

Current flows in the coil → the electromagnet pulls the armature → the armature moves the contact → a separate circuit switches on or off.

Energize the coil, and click — the output circuit closes and a lamp lights. Release it, and click — the lamp goes dark. A switch you never touch, thrown by electricity alone.

Normally open, normally closed: the relay’s two personalities

Here’s the detail that turns a relay from a curiosity into a logic device — and the part the engineers in the room have been waiting for.

A changeover relay commonly provides both normally open and normally closed contacts:

  • Normally open (NO): at rest, the contact is open. Energizing the coil closes it.
  • Normally closed (NC): at rest, the contact is closed. Energizing the coil opens it.

If coil energized is encoded as input 1 and a powered lamp as output 1, the NO path behaves like a buffer and the NC path behaves like NOT. That interpretation depends on the chosen wiring, supply, and logic convention; the contacts themselves are passive switches.

Coil (input)NO contact → lampNC contact → lamp
0 (off)0 (off)1 (on)
1 (on)1 (on)0 (off)

Two columns, two opposite behaviors, from one humble device. The fact that a relay can invert a signal — turn an ON into an OFF — is not a footnote. It’s the spark that makes real logic, and eventually decision-making, possible.

Toggle one yourself

Reading about a click is one thing; operating the model is another. The interactive circuit below represents a relay coil, armature, contact, and lamp. Like every simulator, it is a model: use the visual state and timing to learn the topology, then consult a real relay’s datasheet for voltage, current, delay, bounce, and contact ratings.

Flip the knife switch to send current through the modeled coil. Watch the armature pull in, the contact close, and the lamp light. Optional sound marks each transition.

A single relay, live. Flip the switch to energize the coil; the armature snaps closed and the lamp lights. Turn your sound on for the click.
Open in the Relay Lab

Try this while you play:

  1. Flip it slowly. Notice the delay between energizing the coil and the lamp lighting. A real relay has an electrical and mechanical operate time; contact bounce may add further transitions. Later posts show why all logic technologies—not only relays—must account for finite delay.
  2. Listen. One click to pull in, one click to release. Every click is one bit of the world changing state.
  3. Imagine a rack of them. Electromechanical calculators and relay computers produced a distinctive switching sound as contacts operated.

Why a relay is a useful atom of switching logic

Step back and notice what just happened. The coil’s current controlled the contact’s current. One circuit threw a switch in another circuit.

That’s the property that changes everything, because it means relays can be connected to each other. The output of one relay can be the input — the coil — of the next. A switch that controls a switch that controls a switch. And once devices can control each other, you can arrange them to make decisions: only light this lamp if both of these switches are on; or if either one is; or if this one is not.

If those words—AND, OR, NOT—sound like logic, that is the bridge this series develops. In his 1937 MIT master’s thesis, A Symbolic Analysis of Relay and Switching Circuits, Claude Shannon applied Boolean algebra to the analysis and synthesis of switching networks. Series contacts correspond to conjunction, parallel paths to disjunction, and complemented contact conditions to negation. This made complicated relay networks amenable to systematic mathematical design. You can read the digitized thesis.

Modern processors use semiconductor devices rather than relays, and their transistor-level behavior is not identical to a mechanical contact. The durable connection is abstraction: both technologies can represent two logical states and compose switching elements into Boolean functions.

That’s also why this is such a good place to start learning. You don’t need a circuits degree or a soldering iron to understand a relay — you just watched one work. From this single, visible, audible idea, everything in computing is built up one understandable step at a time. It’s the perfect first rung for a curious kid, a student peeking under the hood, or an engineer who wants to feel the foundations again.

What you just learned — and where we go next

In one post you’ve gone from “a relay is some electrical part” to understanding, from first principles:

  • A relay is a switch that electricity controls — a coil pulls an armature that moves a contact.
  • Wired normally open it’s a buffer; wired normally closed it’s an inverter (a NOT).
  • Because one relay can control another, relays can be chained — and chained switches can compute.

Next in Building a Computer from Relays, we’ll put two switches together and meet the first real logic hiding in plain sight: switches in series behave like AND, switches in parallel behave like OR. You’ll toggle both and feel the rules of logic appear before anyone even names them — setting the stage for Shannon’s big idea.

Want to skip ahead and just play? Every circuit in this series lives in the DigiSim Relay Lab — drag relays onto a canvas, wire them up, and hear a computer think. Start free; the click is waiting.

Apply the concept in a simulator model.