Skip to content

Reference chart

Logic gate truth tables

Print it: Logic gates cheat sheet (PDF: A4 · US Letter)

A logic gate follows one fixed rule, and its truth table lists that rule in full: one row for every way the inputs can be set. Here are all seven gates, how to write each one, and the chips that hold them.

The seven gates

GateWrittenOutput is 1 whenUse it for
NOTĀthe input is 0Flipping a signal
ANDA · Bevery input is 1All conditions at once: a two-hand safety press
ORA + Bany input is 1Any one condition: a car's courtesy light
NANDNOT(A · B)any input is 0Building any other gate
NORNOT(A + B)every input is 0"Nothing is on": every door shut
XORA ⊕ Bthe inputs differStair lights switched from either end, adding bits
XNORNOT(A ⊕ B)the inputs matchChecking two bits are equal

In logic, + means OR, not adding, so 1 + 1 = 1.

NOT

A NOT gate, also called an inverter, has one input and flips it.

ANOT A
01
10

AND, OR and XOR

ABANDORXOR
00000
01011
10011
11110

NAND, NOR and XNOR

A bubble on a gate's output is a NOT, so each of these is the gate above with every answer flipped.

ABNANDNORXNOR
00111
01100
10100
11001

Three inputs

With three inputs there are eight rows. AND gives 1 only on the last row, OR gives 0 only on the first, and XOR gives 1 when an odd number of inputs are 1.

A B CANDORXOR
0 0 0000
0 0 1011
0 1 0011
0 1 1010
1 0 0011
1 0 1010
1 1 0010
1 1 1111

Gate chips

Each chip holds several identical gates with two inputs each, except the inverters. 74HC chips run from 2 to 6 V, so 3.3 V and 5 V boards both suit them; 4000-series chips run from 3 to 18 V.

Gate74HC chip4000-series chipGates in a chip
NOT74HC044069Six
NOT, Schmitt trigger74HC1440106Six
AND74HC084081Four
OR74HC324071Four
NAND74HC004011Four
NOR74HC024001Four
XOR74HC864070Four
XNOR74HC72664077Four

The 74HC00, 74HC08, 74HC32 and 74HC86 share one pinout, but the 74HC02 is wired differently: its outputs come first. Check the datasheet before you swap one chip for another.

Using the tables

  1. Find the inputs and write the rule in words, with "and", "or" and "not".
  2. Turn each word into a gate, with brackets for the order: LIGHT = (DARK · MOTION) + SWITCH.
  3. Check every row of the truth table against what you wanted.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Logic gates” is lesson 2 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 43 before it first.

Or start from the very first lesson, no account needed

Work it out

The ideas behind it

Questions people ask

What is the difference between OR and XOR?

They differ only when both inputs are 1. OR gives 1 there, because at least one input is on. XOR gives 0, because it wants the inputs to differ: one or the other, but not both.

Which logic gates are universal?

NAND and NOR. Each one alone can build every other gate: a NAND with its inputs tied together is a NOT, a NAND then a NOT is an AND, and three NANDs make an OR. That's why chips can be made from NAND cells alone.

Which chip has NAND gates?

The 74HC00 holds four 2-input NAND gates in a 14-pin package, and runs from 2 to 6 V. Its CMOS 4000-series cousin is the 4011, which runs from 3 to 18 V.

How many rows does a truth table have?

One for every way the inputs can be set: 2ⁿ rows for n inputs. A two-input gate has four rows, a three-input gate eight, and a four-input gate sixteen.

More charts