Mr. Clicky-Clack: an 8-Bit Relay-Logic CPU
October 2nd 2024, my friend and I were hanging out, and we got the idea to make a computer out of relays.
Relays (e.g. in Figure 1) are electromechanical switches: you turn an electromagnet on or off, and it flips a switch (often, two switches together) on or off too. They make delightful clicking noises as they do this. How cool would it be to make an entire computer out of that?
Figure 1
: DPDT relay and schematic. Normally, the 'C' terminals are connected to the corresponding 'A' terminals, but when the relay coil is energized, they connect to the 'B' terminals. (Images modified from sources 1 and 2.)It is certainly possible to build a whole computer this way, and in fact some of the earliest computers did just that. The Z3 was one of the earliest to be Turing-complete, and computers were made seriously this way before being phased out by improving vacuum tubes through the 1950s and 1960s.
Today's relays are faster, more reliable, and cheaper. Moreover, Computer Science, a topic in which I have a PhD, has advanced nearly a century. Surely, an individual should be able to make a relay-logic computer without breaking the bank (or the table it sits upon).
Of Previous Work
Now, I'm not the first to have a go at this. In fact, many people have tried (see the table at the end) with various degrees of scope and success. Relays are expensive and fiddly[1], and the required circuit and logic knowledge is not common, so there aren't very many, but it's still a sizable bunch.
All of these projects are interesting and commendable, and I draw considerable inspiration from some. A very few of these projects are pure relay logic, through-and-through. However, the majority implement key pieces of the CPU, such as registers, in non-relay logic, which I don't consider to be fair. In my book, the peripherals, including main memory, may be semiconductors, as may be 'utility' components like flyback diodes and status LEDs, but to count as a proper 'relay-logic computer', the entire functionality of the CPU must be relay-logic.
Design Considerations
The cost of relays suggests the scope of the computer should be something that's as simple as possible (but not too simple; we want it to be useful, after all). This suggests an 8-bit CPU, with no floating-point unit: roughly equivalent to a weak, but real, microcontroller in capability.
Although I had initially planned a somewhat more incremental approach, I decided to skip making a toy architecture and make something properly Turing-complete and with significant capabilities[2]. I named this architecture 'Mr. Clicky-Clack'.
Mr. Clicky-Clack consists mostly of a simple 8-bit CPU of my own design[4]. Central to the CPU is a powerful ALU supporting many bitwise operations and chainable addition / subtraction.
All registers, computation, routing, and control logic—the whole CPU itself—is implemented with relays! However, I chose to implement the non-CPU peripherals with my one true love, the Raspberry Pi Pico. It's simply not interesting to make a gazillion bytes of RAM out of relays, and because this is outside the scope of the CPU even in a real computer, we are excused from having to do so.
Some poking around suggests that 12 V is common. Although a lot of that is doubtless cargo-culting, there is actually a good reason for designing to a higher voltage. Although e.g. 3.3 V relays are readily available, and that's the same voltage as most electronics operate at these days, the issue is that relays take a certain minimum power to work, and lower voltage therefore implies higher amperage (and vice-versa). With the voltages small in absolute terms either way, the design constraint becomes reducing amperage. So a higher voltage it is. Of course, it could be much higher, but 12 V is an easy choice because it is readily available and clearly safe.
However, it is not quite so simple. There are lots of status LEDs to give fun blinkenlights. Powering these with higher voltages results in larger resistors that bleed more energy[5]. And of course, the semiconductor section can't run at all on 12 V without releasing the magic smoke. We can't use 3.3 V for all the LEDs, because some of them actually have that as a forward voltage. So long story short, my computer runs off of three different voltages: 12 V (relays), 4 V (most LEDs), and 3.3 V (electronics).
Much is made of different logic schemes. For example, you could have 12 V mean '1' and disconnected mean '0'. However, I chose the CMOS-like 12 V = '1', 0 V = '0', because that is simple and obvious.
Architecture
Mr. Clicky-Clack is a Harvard architecture two's complement[6] byte-addressed RISC vector machine. It has no pipelining, operating at one instruction per cycle, mainly for simplicity and because instruction decoding is trivial[7].
There are five full 8-bit registers. The first four are 'general-purpose' (for various levels of "general"): "RegA" (A
), "RegB" (B
), "RegC" (C
), and "RegP" (P
). RegA and RegB are the operands of the ALU. RegP ('pointer') indexes memory. However, all of these registers can mean whatever the programmer pleases (not just these primary functions).
The fifth register is the program counter "RegPC" (PC
). This advances automatically by 1 every cycle, unless overridden by a jump command. There are also flag bits, which update on any ALU instruction and may be used by jump commands: ZF (zero flag), SGN (sign bit), CF (carry flag), and OF (overflow flag).
There are four categories of instructions:
- Literals: if the upper bit is
0
, the lower 7 bits are loaded into RegA. - ALU: if the upper bits are
100
, the lower 4 bits control an ALU operation on RegA and RegB (the fifth bit is unused). - Jump: if the upper bits are
101
, the lower 5 bits describe the condition(s) a jump should be taken. Bits 0..4 mean to jump if ZF, CF, SGN, !SGN, or OF, respectively. Multiple bits can be combined (e.g. to make unconditional jumps). - Move: if the upper bits are
11
, the lower 6 bits index a source and destination to move 8 bits to. The lower 3 are the source: zero, port A, port B, memory (at RegP), RegA, RegB, RegC, or RegD. The upper 3 are the destination: RegPC, port A, port B, memory (at RegP), RegA, RegB, RegC, or RegD.
In addition to direct memory access, peripherals can be accessed through two I/O ports. This helps alleviate some of the constraints owing to the small architecture. For example, although RegP can only index 256 B of RAM, one could implement a memory controller that uses a value set on port A and port B as an additional 16 bits of pointer (24 bits, or 16.78 MB of RAM).
A screen could be implemented by writing a gray level onto port A and then writing a command to port B. The commands could be like "set pixel to value on port A", "set coordinates to 0,0", "advance once pixel", "advance one line", etc. Thus it would be pretty easy to touch more pixels than 256 bytes worth, by dumping that responsibility onto the peripheral.
Mr. Clicky-Clack is split up over many printed circuit boards (PCBs), each of which will be discussed individually in following sections:
8-Bit Registers
(⨯5): There are four 8-bit general-purpose registers, and one 8-bit program counter. There are 12 relays per register PCB, for a total of 60 relays.ALU
(⨯1): This implements addition / subtraction and bitwise operations, with a total of 105 relays. The board is planned to be revised and possibly split.Motherboards
(⨯1 each): These boards handle instruction fetch / decoding, interfacing registers, control logic, and so on.Peripherals
(⨯1): This handled interfacing with memory, generating the clock signal, and converting voltages. This is planned to be replaced with simpler and more modular board(s) and off-the-shelf parts.
As more information becomes available, I will split these sections off into their own pages.
In general, I'm going for four-layer PCBs, about 3.5"⨯3.5" square (boards up to 4"⨯4" have the lowest price on JLCPCB), designed in KiCad. The back layer is a full ground plane and the top layer is +12 V, unbroken as much as possible. The middle layers are signal tracks. Tracks are in general 0.02" thick, but certain power tracks are 0.05" thick, as motivated by the following table based on IPC-2221[8]:
Track Type | Max Current[8] (approx amps) | Powered Relays (approx[8]) |
---|---|---|
Internal 0.02" | 0.8921 | 71 |
Internal 0.05" | 1.734 | 137 |
External 0.02" | 1.784 | 141 |
External 0.05" | 3.467 | 274 |

Figure 2
: An unassembled register board[9].8-Bit Register Boards (⨯5)
A register is a tiny piece of memory (stores one number) at the very heart of a CPU. When the CPU goes to, for example, add two numbers together, the numbers it works with are numbers that have been loaded temporarily into two registers.
Mr. Clicky-Clack sports four 'general-purpose' registers: these can be used in whatever way, albeit certain instructions are only available for particular registers. There is a fifth register, the program counter, basically the index of the instruction being executed.
For each of the 8 required bits for each register, we need a memory cell. After designing a better memory circuit myself, it was a simple matter of tiling them into a board with some status LEDs. The total relay cost per board is 12 (1.5 relays/bit).
The boards have been designed and fabricated (Figure 2), but not yet assembled.
ALU Board
The ALU (Figure 3) takes two 8-bit numbers as input, a 4-bit mathematical operation to execute, and returns the result of the mathematical operation.
Roughly speaking, it can do addition / subtraction and the common bitwise operations (it can't do circular shifts, but it can do 'and-not'[10]). Multiplication is not directly supported, but the ALU also emits flags ZF
, SGN
, CF
, OF
, with similar semantics as in x86. With these flags, adds can implement multiplications with fair efficiency in software. Additionally, they allow chained addition, adding efficient support for wider bit-width operations.
The mathematical opcodes and the corresponding operations (as C-like expressions) over operands A and B are:
Opcode | Mathematical Operation | Circuit Implementation |
---|---|---|
0000₂ | A + B | A + B + 0 |
0001₂ | B - A | ~A + B + 1 |
0010₂ | --A | A + 255 + 0 |
0011₂ | A - B | A + ~B + 1 |
0100₂ | ++A | A + 0 + 1 |
0101₂ | -A | ~A + 0 + 1 |
0110₂ | A | A & 255 |
0111₂ | ~A | ~A & 255 |
Opcode | Mathematical Operation | Circuit Implementation |
---|---|---|
1000₂ | A | B | A | B |
1001₂ | A ^ B | A ^ B |
1010₂ | A & B | A & B |
1011₂ | A & ~B | A & ~B |
1100₂ | A >> B | A >> B |
1101₂ | A >>> B | A >>> B |
1110₂ | A << B | A << B |
1111₂ | (undef) | (undef) |
For the size, this is far more capable than any other relay computer I've seen. However, as a consequence of being so demanding, designing this thing was really challenging. All the circuitry for the operations has to work correctly together, and a lot of it needs to be reused or else the board would be truly enormous.

Figure 3
: PCB layout of the current ALU design. (Image by me.)The first step is to decide what the operands even are. In particular, we can bitwise-complement A, bitwise-complement B, or use an alternate constant value (0 or 255) instead of B. There's also a carry input for addition instructions (0 or 1), muxing between addition and bitwise operations, and some miscellaneous. The order of the opcodes above was chosen to optimize the gate-level calculation of these boolean functions.
Bitwise operations are surprisingly easy to do with relay logic (discussed lots more here), and sometimes multiple functions can be done by a single DPDT relay. Taking gate diagrams too literally is not useful; once you get a feel for it, you can just whack down relays and connect them up the right way without any trouble.
Addition is a simple ripple-carry adder. The extra 0 or 1 can be injected as a 'carry' into the first bit.
Because of the complexity of the ALU, I wrote a simulator. This parses the KiCad schematic file and tests that the device produces correct output for every possible input. I was glad to have done this; I found and corrected several bugs this way. The current design has now been exhaustively proven correct!
Although fully designed, I have not yet had this board fabricated.
Motherboards
Despite being central to the operation of the computer, the motherboards' functionality is pretty simple, mostly just shuffling data around to the other PCBs. A single, monolithic motherboard would be too clumsy and expensive. Instead, the current design separates the motherboard into several smaller pieces, which can be tested and fabricated separately.
The first board is the register controller, which interfaces with the four general-purpose registers. Specifically, it is given two bits to determine which register to read back as a possible input to the bus (an 8-wide 2-bit mux), and two bits to determine which register to write to if a write is issued, as well as the write signal itself, if present. Additionally, RegP is read back unconditionally to the memory controller and RegA and RegB are passed unconditionally to the ALU.
The second board interfaces with the program counter. It increments the program counter on a clock tick or overwrites it with a value from the bus if a bit is passed in. The value is passed to the memory controller. The flags (ZF, SGN, CF, and OF) are stored in D flip-flops, and can be written and read as well.
The planned third board handles the rest of the logic, which boils down to checking the instruction type, determining jump conditions, and switching / routing / connecting.

Figure 4
: KiCad rendering of the prototype peripherals board. (Image by me.)Peripherals Board
Mr. Clicky-Clack's peripherals (i.e., the non-CPU components) are on an interfacing board (Figure 4). The peripherals themselves are implemented using a Raspberry Pi Pico. The most significant such component is the computer's RAM.
Also visible (the circuitry at the right) is the buck converter, which converts 12 V to 4 V, with 3 A max current. Calculations suggest it will have 88.2% efficiency, 3.42% tolerance. I probably should have just gone with a dedicated buck converter board from a third party, and I may end up doing so in a redesign.
The vast majority of the board space, however, is taken up with level shifters and bus logic between the 12 V relays and the 3.3 V microcontroller.
Although fully designed, I have not yet had this board fabricated. I may redesign it to be smaller and cheaper.
Counterfeit Relays
Early in the project, I bought 350 relays (the readily available Hui Ke relay model HK19F-DC12V-SHG) on AliExpress for an average price of about $0.23/pc. While I was characterizing the set and release voltages of the relays to spec parts for the registers' D flip-flops, I noticed that the relay coil current was higher than expected. Specifically, the coil power was 0.36 W instead of the expected 0.20 W.

Figure 5
: Composite image showing the evidence: datasheet, ohmmeter, power reading.It turns out, even though I had wanted the "-SDG" part (0.15 W, not easily found) but had settled for the "-SHG" part (0.20 W, easy to find), the seller had sent me "-SG" relays (0.36 W). However, each relay had the "-SHG" label printed on them, which means either someone massively screwed up at the factory, or else a counterfeiter had reprinted the labels on the (presumably less expensive) "-SG" to sell them as "-SHG" to less technically capable buyers, who might never find out.
Counterfeit components are unfortunately common when independently sourcing from China, but I was furious nonetheless. Having each relay eat an additional 80% power almost doubles the amperage through most of the PCBs. Had I not noticed, best case, my power supply would have been unable to power it. Worst case, it could have started an electrical fire and injured, even killed someone. I suppose risking the safety of foreigners is a small price to pay when you stand to profit 1¢ per piece!
Only about 70% of the relays even worked at all anyway. I sent the order back and got a full refund, including shipping. However, I still lost time, motivation, and some faith in humanity. The seller was not apologetic at all, and this garbage is still happily being sold out there.
As a replacement, after doing some more research, I found the J104D2C12VDC.15S relay, which has the same physical footprint and is made by a reputable American company—and these readily available in 0.15 W too. At roughly $1/pc on DigiKey (and even more at lower scale), these were significantly more expensive. However, there's something to be said for actually getting the product you paid for.
The customer support people were nice, even offering a couple pieces as a sample, but were unable to usefully provide technical information missing in the part datasheet, and at times seemed only barely able to understand my admittedly quite technical questions.
While checking the parameters, I was annoyed to notice that, although the datasheet states a coil resistance of 960 Ω (±10%), the coil resistance is actually more like 950 Ω (±0.5%). This is technically in spec, but it's a bias that shows up as consistent slightly higher overall power. It's not enough to matter practically (I had designed for 0.20 W plus margin, after all), but I still consider it deceptive to claim a better value with a lower tolerance, when you know to high tolerance that your actual value is worse.
Fortunately, almost all these new relays worked correctly. Because there are so many relays, even a small chance of mechanical failure becomes likely unless it is very small indeed. I'll be checking each one before installing it. The relays have well controlled set / release voltages, and so I was able to use these relays in the registers' design, as discussed above.
Future Work + Supporting the Project
This project is still under active development, and I hope to finish and document it in the near future. When complete, I will release all designs freely. Pending success of this project, I hope to design a successor 16-bit architecture supporting 16-bit floating-point: a massive, ambitious, and awesome undertaking.
However, even this project is expensive, both in the financial costs (mainly the relays and large PCBs fabrication), as well as in time—there are months worth of work in this project already. I am committed to finishing this project, and have the financial privilege to accomplish it by myself. That said, donations do help offset my financial costs, and make me more enthusiastic about working on it. You may donate to support the project with the links on the main page or my dedicated GoFundMe here:
Standard disclaimers about this project apply, of course, but I think the work presented here so far demonstrates I know what I'm talking about, and have the technical ability to see this through.
Other Relay Computers
Here is an index of the (modern!) relay computers I know about[11][12]. (The ordering is arbitrary.)
Name / Link | Relay Count | Voltage(s) | Description / Notes |
---|---|---|---|
Mr. Clicky-Clack | ≈300 | 3.3, 4.0, 12.0 | This project! |
MERCIA Relay Computer | ≈2000 | A huge relay computer, with solid engineering and many useful notes! (See also.) | |
Harry Porter's Relay Computer | 415 | 12 | Large, influential computer with hand-wired relays in the style of the first relay computers. 32 kiB static RAM, but appears to be pure relay-logic otherwise. |
DiPDoT Relay Computer | 415? | 5 | A relay computer by user 'DiPDoT', based on Harry Porter's Relay Computer, but implemented with custom PCBs, mostly updating on YouTube. |
RC-3 Relay Computer | 418 | 12? | Inspired by Harry Porter's relay computer. Due to Phil Ryals and folks at the Museum of Computer Culture[13], comes with lots of documentation. See a run of it here! |
Carl Hasbargen's Relay Computer / RC-C | 413 | 12 | Based on Harry Porter's relay computer with a different build and additional features. Carl provided a writeup, which is hosted here! |
Relay Computer One / Two | 281 | 12 | Inspired by Harry Porter's relay computer. Sells generic relay-logic modules, good descriptions of relay-logic gates. |
Paul Law's Relay Computer, based on Harry Porter's relay computer. | Also on Hackaday. | ||
DAVIAC | 416 | 12 | Multiple relay sizes, with a good build quality. Makes delightful (1) rhythm (2)! |
RISC Relay CPU | 327 | 24 | Partially completed (but still functional) ambitious relay computer. |
Single Board Relay Computer / Relay Trainer | 83 | 12 | Mostly a relay-logic ALU driven by a conventional microcontroller; the core is implemented with relays, but all registers except the PC and some control logic are in silicon. Good peripherals and controls. Influential D-flip-flop design has been widely copied. (See also.) |
Zusie | (100–1500?) | ??? | Inspired by Zuse architectures. |
R500/7T Relay Computer | ≈500 | Heavy clicking, good build, useful demo calculating the day of the week of a date. (See also parent site.) | |
R200 Relay Computer | ≈200 | No ICs. | |
"High Performance" Relay Computer | 100? | 24? | 16-bit architecture with SPDT relays (quotes original). (See also.) |
relaiscomputer.de | 171 (1500 planned?) | Inspired by the Z3. Seems to be old project. | |
Will Dana's Relay Computer | |||
Super Micro Relay Computer | 46 | 12 | 4PDT relays, design optimized for simplicity. |
RR6: The Reed Relay 6-bit Computer | 216 | 5–9 | 112 DPST reed relays + 104 DPDT relays, PROM implemented with DIP switches. |
i2 8-Bit Relay Computer | >300 | 6 | Draws elements from Harry Porter's relay computer (RC2), as well as RC2, RC3, and Zusie. |
Tim 8 (and earlier) | 152 | 12 | Appears to be an older project. SPDT relays, ingenious RAM solution! Also on Hackaday. |
BrainfuckPC Relay Computer | 567 | 16-bit relay-logic computer made out of 439+64+64 Soviet reed relays, with 128 kiB RAM IC. (See also.) | |
machinedeturing.com | 12 | Turing machine implemented using relay-logic. | |
Duo 14 Premium | ≈50? | 2-bit relay computer. |
Back to Electronics Projects.