Digital Logic
AND and NOT gates explained
An AND gate outputs 1 only when all of its inputs are 1; any 0 makes the output 0. A NOT gate, or inverter, has one input and outputs the opposite: 1 in, 0 out, and 0 in, 1 out. In Boolean algebra, A AND B is written A · B, and NOT A is written Ā.
The truth tables
A truth table lists every input combination with its output. Two inputs can be set four ways:
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
AND's table has a single 1, on the last row. NOT's table has just two rows: 0 gives 1, and 1 gives 0. Put two NOTs in a row and they cancel, giving back the original input.
Live experiment
Fill in the table
Two switches into an AND gate, with Pip as the probe on its output. Each setting you try lights its row of the truth table and fills in the output. Try all four rows and see how many 1s AND gives. Then switch to NOT, which has only two rows.
“NOT and AND” is lesson 2 of 6 in Gate Grove, Digital Logic World 1. Free with an account. Lessons unlock in order, so you’ll do the one before it first.
AND is switches in series
Wire two switches in series with a lamp, and the lamp lights only when both are closed: that's AND made of switches. In code it's &&: if (keyTurned && doorShut) runs only when both are true.
More than two inputs
Most AND gates on a chip take two inputs. For three signals, AND two of them, then AND that result with the third. A gate's output is just a wire, so it can feed another gate's input as easily as a switch can. Four inputs take three 2-input ANDs.
Two hands and a guard
Industrial presses run only when the operator presses two buttons, one per hand, so neither hand can be under the press, and the safety guard is not open:
That's a NOT on the guard's sensor and two ANDs. With both hands pressed and the guard open, NOT(OPEN) is 0, so RUN is 0: one 0 into an AND outweighs every 1.
Chips to build with
The 74HC08 holds four 2-input AND gates and the 74HC04 holds six NOT gates, each in a 14-pin package on a 2 to 6 V supply. Every unused input must be tied high or low: a floating CMOS input can read either way.
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.
“NOT and AND” is lesson 2 of 6 in Gate Grove, Digital Logic World 1. Free with an account. Lessons unlock in order, so you’ll do the one before it first.
Or start from the very first lesson, no account neededWork it out
Practice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: 0. AND needs both inputs at 1. One is not enough, whichever one it is, so the output is 0.
- Why not “It depends on which input”? AND treats its inputs the same way round. A 0 on either one gives 0.
- Why not “Half”? Logic gates have no halves: the output is a 1 or a 0, and here it's 0.
- Why not “1”? A 1 out needs both inputs at 1. With one input at 0, AND gives 0.
Show the answer
Answer: No. NOT(guard open) is 0 while the guard is open, and AND with a 0 gives 0. Both hands count for nothing until the guard is closed.
- Why not “It depends on the order”? AND doesn't care about order, only whether every input is 1 right now.
- Why not “Only briefly”? A gate's output follows its inputs at every moment. While the guard is open, the output stays 0.
- Why not “Yes”? Both hands are pressed, but NOT(guard open) is 0 while the guard is open, and AND with a 0 gives 0.
Show the answer
Answer: Both inputs are 1. Both, or nothing.
- Why not “The inputs differ”? Inputs that differ is XOR's rule. AND gives 0 when they differ.
- Why not “Both are 0”? Both at 0 gives 0 from AND. Its only 1 is when both inputs are 1.
- Why not “Either input is 1”? Either input at 1 is OR's rule. AND needs both.
“NOT and AND” is lesson 2 of 6 in Gate Grove, Digital Logic World 1. Free with an account. Lessons unlock in order, so you’ll do the one before it first.
Questions people ask
What is the truth table of an AND gate?
Four rows for two inputs: 0 and 0 give 0, 0 and 1 give 0, 1 and 0 give 0, and 1 and 1 give 1. The output is 1 only on the row where every input is 1.
How do you make a 3-input AND gate?
AND two of the inputs, then AND that result with the third. Two 2-input gates in a chain give exactly the 3-input table, because a gate's output is just another wire. Chips with 3- and 4-input ANDs exist too, like the 74HC11.
What is a NOT gate used for?
Anywhere a signal means the opposite of what you need: a pull-up button that reads 0 when pressed, a sensor that's 1 when a door is open, or a rule like 'run only when the guard is NOT open'. It's also called an inverter.
Related topics
- Logic gates explainedAND, OR, NOT, XOR and their bubbled twins: each one's rule is a truth table.
- Why is NAND called a universal gate?NOT, AND, OR and XOR from one kind of gate, and why chips love it.
- How to make a truth tableEvery input combination and its output: the complete, unarguable description of a logic circuit.
- De Morgan's laws explainedPush a NOT through a gate: every input flips and AND swaps with OR.