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
| Gate | Written | Output is 1 when | Use it for |
|---|---|---|---|
| NOT | Ā | the input is 0 | Flipping a signal |
| AND | A · B | every input is 1 | All conditions at once: a two-hand safety press |
| OR | A + B | any input is 1 | Any one condition: a car's courtesy light |
| NAND | NOT(A · B) | any input is 0 | Building any other gate |
| NOR | NOT(A + B) | every input is 0 | "Nothing is on": every door shut |
| XOR | A ⊕ B | the inputs differ | Stair lights switched from either end, adding bits |
| XNOR | NOT(A ⊕ B) | the inputs match | Checking 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.
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND, OR and XOR
| A | B | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
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.
| A | B | NAND | NOR | XNOR |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 1 |
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 C | AND | OR | XOR |
|---|---|---|---|
| 0 0 0 | 0 | 0 | 0 |
| 0 0 1 | 0 | 1 | 1 |
| 0 1 0 | 0 | 1 | 1 |
| 0 1 1 | 0 | 1 | 0 |
| 1 0 0 | 0 | 1 | 1 |
| 1 0 1 | 0 | 1 | 0 |
| 1 1 0 | 0 | 1 | 0 |
| 1 1 1 | 1 | 1 | 1 |
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.
| Gate | 74HC chip | 4000-series chip | Gates in a chip |
|---|---|---|---|
| NOT | 74HC04 | 4069 | Six |
| NOT, Schmitt trigger | 74HC14 | 40106 | Six |
| AND | 74HC08 | 4081 | Four |
| OR | 74HC32 | 4071 | Four |
| NAND | 74HC00 | 4011 | Four |
| NOR | 74HC02 | 4001 | Four |
| XOR | 74HC86 | 4070 | Four |
| XNOR | 74HC7266 | 4077 | Four |
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
- Find the inputs and write the rule in words, with "and", "or" and "not".
- Turn each word into a gate, with brackets for the order: LIGHT = (DARK · MOTION) + SWITCH.
- 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.
“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 neededWork it out
The ideas behind it
- Logic gates explainedAND, OR, NOT, XOR and their bubbled twins: each one's rule is a truth table.
- How to make a truth tableEvery input combination and its output: the complete, unarguable description of a logic circuit.
- AND and NOT gates explainedAND needs every input at 1; NOT flips its one input. Together they build safety interlocks and masks.
- What is an XOR gate?1 when the inputs differ, 0 when they match: the gate behind stair lights, adders and parity bits.
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
- Standard resistor values chartThe E12, E24 and E96 series, decade by decade, and which one to reach for.
- SMD resistor code chartTurn 472, 4702, 4R7 or 01C on a tiny resistor into ohms.
- LED forward voltage by colourEach colour's forward voltage, and how many LEDs fit in series on 5 V, 9 V or 12 V.
- Electronics unit prefixes and conversionsp, n, µ, m, k, M and G, conversion tables, and what 4k7 or 2n2 means.
- Capacitor code chartTurn 104, 473J or 2A into a value, a tolerance and a voltage rating.
- Common diodes chart1N4148, 1N4007, 1N5819 and the 1N47xx Zeners compared, and which one to use.
- Common transistors chartRatings, gain and pinouts for the BJTs and MOSFETs in every parts kit.
- Arduino Uno pins and limitsWhich Uno pin does what, and how much current each pin and the whole board can give.
- Binary, decimal and hex table0 to 15 in all three bases, the powers of two, common bytes, and converting four bits at a time.
- AWG wire gauge chartAWG and mm² side by side, ohms per metre, and roughly how many amps each size takes.
- Battery voltage and capacity chartFull, nominal and flat voltages, typical mAh, and how full a lithium cell is from its voltage.
- Electronics formulas cheat sheetOhm's law to antenna length: every formula in the course, what it gives and where to learn it.
- Electronics glossaryFrom AC to Zener diode: the words of electronics, each in a sentence or two.