A circuit that adds is the heart of every computer, and you now have everything needed to build one. First, the arithmetic. In , each place is worth twice the one to its right: 1, 2, 4, 8, and so on. Each column is named after what a 1 in it is worth, as everyday numbers have a units column, a tens and a hundreds: on the right the 1s (read “ones”), then the 2s, the 4s and the 8s. A 1 in the 4s column means 4, and a 0 in any column means nothing. So 11 means 2 + 1 = 3, and 10 means 2. Each digit is a , and in a circuit, one wire.
Binary addition follows the same column rules as the addition you learned at school, with only two digits:
| Add | Gives | Written |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 1 |
| 1 + 0 | 1 | 1 |
| 1 + 1 | 2 | 0, carry 1 |
Compare the last column with part 4. The digit written down is 1 when the two bits differ: that is XOR. The carry is 1 only when both bits are 1: that is AND. Two gates, and you can add two bits.
To add 3 + 2, line up 11 and 10. The right-hand column, the 1s: 1 + 0 = 1, no carry. The left-hand column, the 2s: 1 + 1 = 0, carry 1, which becomes a new column on the left. The answer is 101, which is 4 + 1 = 5.
The XOR and the AND that add two bits are called a . It is only half the job, because every column except the first must also add the carry from the column to its right: three bits, not two.
A does that. It adds the column’s two bits with an XOR, then adds the incoming carry to the result with a second XOR. A carry goes out of the column if both bits were 1, or if their sum was 1 and a carry came in:
sum = A ⊕ B ⊕ carry in
carry out = A·B + (A ⊕ B)·carry in
That is two XORs, two ANDs and an OR: five gates. Chain full adders, each one’s carry out feeding the next one’s carry in, and you can add numbers as long as you like; the carry “ripples” from column to column. Two bits need one half adder and one full adder: three XORs, three ANDs and one OR, which fit on one 74HC86, one 74HC08 and one 74HC32 with gates to spare.
People were building adders like this before chips existed. In November 1937 George Stibitz, a mathematician at Bell Labs, built a binary adder out of relays. He later called it the Model K, after the kitchen table it was said to have been assembled on.
A two-bit adder
Set A and B with the four switches; A1 and B1 are the 2s, A0 and B0 the 1s. The three LEDs on the right show the sum in binary. Watch the carry leave the 1s column and arrive in the 2s.
11 + 10 = 1013 + 2 = 5
1s column: 1 + 0 = 1. 2s column: 1 + 1 = 0, carry 1 into the 4s. The LEDs read 101: a 1 in the 4s and a 1 in the 1s, so 4 + 1 = 5.
1s, 2s and 4s name the columns by what a 1 in each is worth, as units, tens and hundreds do in everyday numbers. The same seven gates as the wiring diagram below: the XOR and AND at the top left are the half adder for the 1s, the rest the full adder for the 2s. Every wire is orange when it carries a 1.
The adder is the biggest build in the series, but it is the same few connections repeated: every gate is a gate you have tested, and every pin is on a pinout you have read. Build it chip by chip, and test each chip’s outputs before adding the next.
Place the three chips side by side, notches to the left, each powered and decoupled as always: the 74HC86, then the 74HC08, then the 74HC32. Then wire them by this table:
| From | To | Carries |
|---|---|---|
| A0 | 74HC86 pin 1 and 74HC08 pin 1 | the 1s bit of A |
| B0 | 74HC86 pin 2 and 74HC08 pin 2 | the 1s bit of B |
| A1 | 74HC86 pin 4 and 74HC08 pin 4 | the 2s bit of A |
| B1 | 74HC86 pin 5 and 74HC08 pin 5 | the 2s bit of B |
| 74HC08 pin 3 | 74HC86 pin 9 and 74HC08 pin 9 | C0, the carry from the 1s |
| 74HC86 pin 6 | 74HC86 pin 10 and 74HC08 pin 10 | X, A1 ⊕ B1 |
| 74HC08 pin 6 | 74HC32 pin 1 | G, both 2s bits were 1 |
| 74HC08 pin 8 | 74HC32 pin 2 | P, a carry passed through |
| 74HC86 pin 3 | 330 Ω and LED | the 1s of the answer |
| 74HC86 pin 8 | 330 Ω and LED | the 2s |
| 74HC32 pin 3 | 330 Ω and LED | the 4s |
The simplest switch is a jumper wire: one end in an input’s strip, the other moved by hand between the + rail for 1 and the − rail for 0. A wire that is always in one rail or the other never floats, so it needs no pull-down. A DIP switch can only connect or disconnect, so each of its inputs needs a pull-down, with the switch to +5 V, as for a button.
Tie every unused input to ground: pins 12 and 13 of the 74HC86 and the 74HC08, and pins 4, 5, 9, 10, 12 and 13 of the 74HC32. Line the three LEDs up in order, 4s on the left and 1s on the right, so they read as a binary number.
With all inputs at 0, every LED is off. A = 01 and B = 01 gives 010: only the 2s LED. A = 11 and B = 11 gives 110, which is 6, the biggest answer. Work through all sixteen combinations; each should match the instrument.
The second project needs only the 555 clock from part 11 and one 74HC74. Part 11 built a flip-flop that toggles, with fed back to D: its output changes once for every two clock ticks. Now chain a second toggling flip-flop after it, clocked not by the 555 but by the first flip-flop’s .
Follow it through. The first flip-flop, the 1s, toggles at every tick. Each time it falls from 1 to 0, its rises, and the second flip-flop, the 2s, toggles. Read the two LEDs as a binary number, 2s on the left, and the sequence is 00, 01, 10, 11, 00 … the circuit is counting. Each stage toggles half as often as the one before it, so a third stage would count the 4s, and a fourth the 8s. This chain is a ripple , because each stage triggers the next, like the carry in the adder.
The counter
Watch the LEDs count in binary, and follow the timing diagram: each output changes half as often as the one above it. Pause and step one clock pulse at a time, or add a second 74HC74 for four bits.
The 1s flip-flop toggles at every rising edge of the clock. Each of the others toggles when the one before it falls from 1 to 0, which is when a carry moves left.
Rising-edge flip-flops, each clocked by the /Q of the one before. In a real ripple counter each stage switches a few nanoseconds after the one before it, far too fast to see here.
The ripple has a cost. Because each stage waits for the one before it, the outputs change a few nanoseconds apart, and for an instant the count can show a wrong value, such as 00 on its way from 01 to 10. LEDs are far too slow to show it, but a circuit reading the count at that instant would. Faster designs use a synchronous counter, in which every flip-flop shares the same clock and extra gates decide which ones toggle.
- Keep the 555 clock from part 11 on one end of the board. Put the 74HC74 beside it, powered and decoupled.
- Tie both flip-flops’ and to +5 V: pins 1, 4, 10 and 13. The bar marks them : they act at 0, so holding them at 1 keeps them out of the way.
- First flip-flop: the 555’s pin 3 to pin 3, and pin 6 () to pin 2 (D).
- Second flip-flop: pin 6 also to pin 11 (its clock), and pin 8 () to pin 12 (D).
- An LED and 330 Ω on pin 5 (the 1s) and on pin 9 (the 2s), with the 2s LED on the left.
- Optional: to clear the count, take pins 1 and 13 to a 10 kΩ pull-up instead of straight to +5 V, and add a button from them to ground. Pressing it is an active-low clear, as in part 10.
The LEDs count 00, 01, 10, 11 and start again, one step a second: the 1s LED blinks at half the clock’s rate and the 2s LED at a quarter. Pressing the optional clear button sets both to 0, and counting resumes from there.
Twelve parts ago this series began with a bare breadboard. You can now light an LED safely, read inputs without floating, use every common gate and build any of them from NANDs, write a rule as Boolean algebra and simplify it, read a chip’s pinout and datasheet, make a circuit remember, give it a clock, and add and count in binary. That is the foundation of every digital machine.
Three directions build on it:
- Bigger building blocks. The 7400 family has chips for whole jobs you have now built by hand: the 74HC283 adds two 4-bit numbers, the 74HC393 holds two 4-bit ripple counters, the 74HC161 is a synchronous counter, and the 74HC4511 turns a binary count into the digits of a seven-segment display.
- Connect the two projects. Feed the counter’s outputs into one input of the adder, and set the other with switches: a circuit that adds a fixed number to a count that keeps going up. Every processor adds and counts, billions of times a second, with circuits built on these same ideas.
- Microcontrollers. A small programmable chip, such as those on Arduino or Raspberry Pi Pico boards, runs a program instead of a fixed wiring. Inside, it is gates and flip-flops, and outside it needs exactly what you now know: pull-ups or pull-downs on its inputs, resistors on its LEDs, decoupling on its supply, and a clock.
Whichever you choose, keep the breadboard. The fastest way to understand a circuit is still to build it, press the button, and see whether the LED does what you expected.
Sources for this part
Adders
Counters