Skip to content

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:

ABA AND B
000
010
100
111

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.

Try it yourself: free lesson

“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:

RUN = HAND1 · HAND2 · 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.

Try it yourself: free lesson

“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 needed

Work it out

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3An AND gate has one input at 1 and the other at 0. Its output is…
    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.
  2. Question 2 of 3A machine runs when both hand buttons are pressed AND the guard is NOT open. Hands pressed, guard open. Does it run?
    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.
  3. Question 3 of 3AND outputs 1 when…
    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.
Keep practising: free lesson

“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.

Every topic