Relay Lab · Chapter 0 of digital logic

Where does a logic gate actually come from?

Before the transistor, computers thought in copper and clicks. Drag mechanical relays onto a canvas, wire them up, and watch a real circuit compute — armatures snapping shut, contacts sparking, every click the genuine sound of a 1940s machine. This is the physical layer beneath every AND gate.

A logic gate isn't magic. It's a switch pulled shut by a magnet.

Every gate you've ever used comes down to three physical ideas. Watch them happen, one relay at a time.

bolt

1 · The electromagnet

Send current through the coil and it becomes a magnet, pulling an iron armature down toward it.

swap_horiz

2 · The contact

That moving armature flips a switch — closing one path, opening another. Now electricity controls electricity.

account_tree

3 · The logic

Wire relays in series and you have AND. In parallel, OR. Flip a contact and you have NOT. That's the whole gate set — built from metal.

Not an animation. A simulation.

Under the canvas runs a real DC circuit solver. Nothing here is faked for show.

electric_bolt

Real volts and amps

Ohm's law and Kirchhoff's laws solve the actual node voltages and currents. Lamps dim by the power they dissipate.

precision_manufacturing

Mechanically faithful

Armature, spring, and contact geometry move like real hardware — a 22 ms pull-in, and a staggered cascade as one relay trips the next.

graphic_eq

The genuine sound

Every click is a recorded Omron relay, fired at the exact moment its contacts make or break. Turn the sound on and hear a computer think.

translate

Seven languages

The whole lab — menus, labels, every example — speaks English, 中文, 日本語, Español, 한국어, Deutsch, and Français.

Chapter 0, then the climb.

DigiSim takes you from a single AND gate to a working 8-bit CPU. The Relay Lab adds the rung beneath it — so you don't just use a gate, you build one from the metal up. When you're ready, keep climbing.

  1. 1 Relay You are here
  2. 2 Logic gate
  3. 3 Adder
  4. 4 Memory
  5. 5 8-bit CPU

24 circuits, ready to run.

Every example is fully wired — load it, flip the inputs, watch the relays cascade. They follow the chapters of Charles Petzold's CODE, so the set reads like the book.

toggle_on

Basics

  • The relay
  • Switches in series (AND)
  • Switches in parallel (OR)
Open in the Lab
memory

Logic gates

  • NOT
  • AND
  • OR
  • NAND
  • NOR
  • XOR
  • XNOR
  • 2:1 multiplexer
Open in the Lab
calculate

Arithmetic

  • Half adder
  • Full adder
  • 2-, 4- and 8-bit adders
  • Adder / subtractor
Open in the Lab
cached

Feedback

  • Relay oscillator
  • R-S flip-flop
  • D latch
  • D flip-flop
  • Frequency divider
Open in the Lab
save

Memory

  • 1-bit memory cell
  • 3-bit ripple counter
Open in the Lab

Reading CODE? Build every circuit from the book.

Charles Petzold's CODE traces computing from a flashlight to a CPU — and the relay is where it gets real. The lab's examples follow the book's chapters, so you can read a page, then watch it turn into a working machine.

Start with “The relay”

Free to play. No login, no setup.

The Relay Lab runs entirely in your browser — drag, wire, and run all 24 examples without an account. When you're ready for the full toolkit — 60 components, saved circuits, and the whole path to a CPU — that's where the tiers come in.

Hear a computer think.

Open the lab, drop in a relay, and flip the switch. (Sound on.)

Open the Relay Lab