Every logic gate, built from NAND

A NAND gate is on unless both of its inputs are on. That one rule is enough to build every other gate: tie a NAND's inputs together and it's a NOT, put that NOT after a NAND and it's an AND, and put NOTs in front of a NAND and it's an OR. That's why NAND is called a universal gate.

Flip A, then turn on B and C. Every gate here is a NAND.

How it works

  1. 01

    A NAND is an AND with its answer flipped: it's off only when both inputs are on, and on the rest of the time.

  2. 02

    Wire both inputs of one NAND to the same switch. It only ever sees 1 and 1, or 0 and 0, so it turns 1 into 0 and 0 into 1: a NOT.

  3. 03

    Put that NOT after a NAND and it flips the answer back. Two NANDs make an AND.

  4. 04

    Flip both inputs first, then NAND them: the output is on when either one is on. Three NANDs make an OR.

What each light does

  • NOT A = A'
  • B AND C = B·C
  • D OR E = D + E

Every circuit in the library