Built-in project · no microcontroller

Full adder

Three 74HC chips add two bits and a carry, with the sum and carry on LEDs. There is no microcontroller in it: the simulator solves the 10 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

Teaching? Assign it to your class in one click.

Advanced About 30 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $6.95. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • Binary addition with a sum and a carry
  • XOR, AND and OR logic gates
  • Truth tables
  • Building arithmetic from simple gates
  • Powering logic chips and LEDs
  • Difficulty: Advanced
  • Time: About 30 minutes
  • Parts: 12

How it works

Three slide switches set bit A, bit B and the carry-in. Three logic chips add them: a 74HC86 XOR, a 74HC08 AND and a 74HC32 OR. A green LED shows the sum and a red LED shows the carry.

The sum is A xor B xor carry-in, made by two XOR gates in a row. The carry is (A and B) or ((A xor B) and carry-in), made by two AND gates feeding one OR gate.

Try 1 + 1 + 0: the sum LED goes off and the carry LED lights, because the answer is binary 10. Chain eight of these adders and you have the adder in an 8-bit CPU.

Parts list

12 parts, plus the jumper wires. They retail for about $6.95; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
Slide switch (1) pin 35 V
Slide switch (2) pin 35 V
Slide switch (3) pin 35 V
74HC86 quad XOR pin VCC5 V
74HC08 quad AND pin VCC5 V
74HC32 quad OR pin VCC5 V
Slide switch (1) pin 1Ground
Slide switch (2) pin 1Ground
Slide switch (3) pin 1Ground
74HC86 quad XOR pin GNDGround
74HC08 quad AND pin GNDGround
74HC32 quad OR pin GNDGround
LED, green pin CGround
LED, red pin CGround
74HC86 quad XOR pin 1ASlide switch (1) pin 2
74HC08 quad AND pin 1ASlide switch (1) pin 2
74HC86 quad XOR pin 1BSlide switch (2) pin 2
74HC08 quad AND pin 1BSlide switch (2) pin 2
74HC86 quad XOR pin 2BSlide switch (3) pin 2
74HC08 quad AND pin 2BSlide switch (3) pin 2
74HC86 quad XOR pin 2A74HC86 quad XOR pin 1Y
74HC08 quad AND pin 2A74HC86 quad XOR pin 1Y
Resistor, 220 Ω (1) pin 174HC86 quad XOR pin 2Y
74HC32 quad OR pin 1A74HC08 quad AND pin 1Y
74HC32 quad OR pin 1B74HC08 quad AND pin 2Y
Resistor, 220 Ω (2) pin 174HC32 quad OR pin 1Y
LED, green pin AResistor, 220 Ω (1) pin 2
LED, red pin AResistor, 220 Ω (2) pin 2

The notes that come with it

There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.

sketch.ino
// A full adder: three chips, two LEDs, one bit of arithmetic.
//
// Set A, B and the carry-in on the three slide switches and read the answer:
//
//   A B Cin   carry sum
//   0 0  0      0    0      0 + 0 + 0 = 0
//   1 0  0      0    1      1 + 0 + 0 = 1
//   1 1  0      1    0      1 + 1 + 0 = 2
//   1 1  1      1    1      1 + 1 + 1 = 3
//
// Sum is A xor B xor Cin: two XOR gates from the 74HC86 in series.
// Carry is (A and B) or ((A xor B) and Cin): two ANDs from the 74HC08 into one
// OR from the 74HC32.
//
// Chain eight of these, carry-out to carry-in, and you have the adder in an
// 8-bit CPU. That is the whole trick: there is nothing else in there.
//
// Watch the wires while you flip a switch: the canvas tints each net by its
// logic level, so you can follow a 1 through the XOR and out of the carry.

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • An LED is always on or always off This project
    Check that each chip has its VCC on 5 V and GND on ground. Then check the gate inputs against the wiring.
  • The carry LED lights at the wrong times This project
    Check the two AND outputs both go into the OR chip, and that the second AND takes the XOR result and the carry-in.
  • The input reads random values in one position. Slide switch
    A switch only connects or disconnects. Add a pull-up or pull-down resistor, or use INPUT_PULLUP, so the pin has a defined level when the switch is open.
  • The load never turns on when the switch is flipped. Slide switch
    Use the center (common) leg and one outer leg. The unused outer leg goes nowhere. Check that the switch is in series with the load.
  • Unused XOR inputs float, giving random outputs and extra supply current. 74HC86 quad XOR
    Tie every unused input to GND or VCC. Add a 0.1 uF capacitor between VCC and GND near the chip.
  • The output is the opposite of what you expected. XOR is high only when the two inputs differ. 74HC86 quad XOR
    Check the truth table: 0 and 0 gives 0, 1 and 1 gives 0. Use a XOR with one input tied high to make an inverter. Power the chip at 2 V to 6 V.
  • Unused gate inputs are left floating, so the outputs flicker and the chip heats up. 74HC08 quad AND
    Tie every unused input to GND or VCC. Add a 0.1 uF capacitor between VCC and GND close to the chip. Join all grounds.
  • The chip gets the wrong supply. A 74HC runs from 2 V to 6 V, and inputs must not go above VCC. 74HC08 quad AND
    Power pin 14 with 5 V or 3.3 V and pin 7 with ground. Keep logic inputs between 0 V and VCC.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.