Back to Lesson

Teacher Guide: Logic Gates

Learn how AND, OR, NOT, XOR, NAND and NOR gates turn 1s and 0s into decisions, and how to find the output of a small circuit.

Use this lesson with your class

Free, no student accounts needed.

Share with students

Students open the lesson and practise with instant feedback.

Printable worksheet

All practice problems on paper, with a separate answer key.

Class quiz

10 questions on Boolean Logic. Students join with a name, you see everyone's score.

For Teachers

Learning Objectives
  • Explain what a logic gate is and what the inputs and outputs 1 and 0 stand for
  • Recall the truth tables of the AND, OR, NOT, XOR, NAND and NOR gates
  • Find the output of a circuit with 2 or 3 gates for given inputs
  • Write the Boolean expression of a circuit described in words
  • Describe real uses of logic gates, such as alarms and the half adder
Prerequisites
  • • The AND, OR and NOT operations and their truth tables (The AND Operation, The OR Operation, The NOT Operation)
  • • Building truth tables for 2 and 3 variables (Truth Tables)
  • • Evaluating Boolean expressions with brackets (Compound Boolean Statements, Boolean Expressions)
Discussion Starters
  • 1. Where in your home is a decision made by AND (two things must both be true)? Where by OR?
  • 2. A light on a staircase can be switched from the top and from the bottom. Which gate describes it, and why?
  • 3. Why might a factory prefer to build every chip from just one kind of gate?
  • 4. How can a machine that only knows 1 and 0 add numbers like 25 + 17?
Common Misconceptions

OR means one or the other but not both

Remediation: In everyday language or often means exclusive or. Put the OR and XOR columns side by side and point to the row with inputs 1, 1. Use a doorbell with a button at the front door and one at the back door: if both are pressed at once, it still rings (OR).

1+1=21 + 1 = 2 also holds for gates

Remediation: Remind students that a gate output is a single wire that can only be on or off. Write 1+1=11 + 1 = 1 (OR) next to 1+1=1021 + 1 = 10_2 (binary addition with a half adder) and discuss the difference.

In a circuit every gate works with the original inputs

Remediation: Have students label every wire with its value, gate by gate, like a relay race where each runner only gets the baton from the previous runner.

Differentiation Ideas

For Struggling Students:

  • • Start with AND, OR and NOT only, using the light switch picture (on = 1, off = 0)
  • • Give a printed gate table to look up while tracing circuits
  • • Use circuits of only 2 gates with the inputs already filled in

For On-Level Students:

  • • Trace circuits of 3 gates for several input combinations
  • • Write Boolean expressions for circuits described in words, and the reverse
  • • Build the half adder table and identify the XOR and AND gates

For Advanced Students:

  • • Show how NOT, AND and OR can be built from NAND gates only
  • • Design a majority circuit for three inputs and count its rows with output 1
  • • Research the full adder and how 4 of them add two 4-bit numbers
Standards Alignment
  • CCSS.MATH.PRACTICE.MP4 (MP4)

    Model with mathematics

  • CCSS.MATH.PRACTICE.MP6 (MP6)

    Attend to precision

  • CCSS.MATH.PRACTICE.MP7 (MP7)

    Look for and make use of structure

Lesson Resources
  • visualInteractive Gate Table

    Students switch between the six gates, read each truth table and see the gate symbol for AND, OR, NOT and XOR

  • activityHuman Circuit

    Students act as gates, hold up 1 or 0 cards and pass their output to the next student in the circuit

  • worksheetTrace the Circuit

    Circuits of 2 and 3 gates described in words: find the output and write the Boolean expression

Lesson Content

Everything students see: definition, examples, common mistakes, applications. Tap to open.

Definition

A logic gate is a tiny electronic circuit with one or two inputs and one output. Every input and every output is either 1 or 0:
  • 1 = voltage on (high), which means true
  • 0 = voltage off (low), which means false
Each gate performs one Boolean operation. Gates are the hardware version of AND, OR and NOT from the earlier lessons.
The two-input gates (inputs AA and BB, rows start with 0,00, 0):
AABBANDORXORNANDNOR
0000011
0101110
1001110
1111000
The NOT gate (also called an inverter) has only one input and flips it: input 0 gives output 1, input 1 gives output 0.
How to remember them:
  • AND: output 1 only when both inputs are 1
  • OR: output 1 when at least one input is 1
  • XOR (exclusive OR): output 1 when the inputs are different
  • NAND (NOT AND): the opposite of AND, output 0 only when both inputs are 1
  • NOR (NOT OR): the opposite of OR, output 1 only when both inputs are 0
Notation: engineers often write A⋅BA \cdot B for AND, A+BA + B for OR and A‾\overline{A} for NOT. They mean exactly the same as A∧BA \land B, A∨BA \lor B and ¬A\neg A. XOR is written A⊕BA \oplus B, NAND is A⋅B‾\overline{A \cdot B} and NOR is A+B‾\overline{A + B}. Careful: here 1+1=11 + 1 = 1, because ++ means OR.
A circuit connects gates: the output of one gate becomes an input of the next. To find the final output, go from the inputs to the output, one gate at a time.
The interactive table in this lesson uses AA and BB for the inputs and 1, 0 for the values. It draws the symbol of every gate, NAND and NOR included.

Worked Examples

The inputs are A=1A = 1 and B=0B = 0. Find the output of an AND, OR, XOR, NAND and NOR gate.

1

AND gate

AND needs both inputs to be 1, but B=0B = 0 → AND: 00

2

OR gate

OR needs at least one 1, and A=1A = 1 → OR: 11

3

XOR gate

The inputs 11 and 00 are different → XOR: 11

4

NAND gate

NAND is the opposite of AND: AND gave 00, so flip it → NAND: 11

5

NOR gate

NOR is the opposite of OR: OR gave 11, so flip it → NOR: 00

Common Mistakes

Thinking an OR gate gives 00 when both inputs are 11

Why it's wrong: That is the XOR gate. OR is 1 when at least one input is 1, and that includes the case where both are 1.

Correct: OR: 1∨1=11 \lor 1 = 1. XOR: 1⊕1=01 \oplus 1 = 0. Only XOR asks for the inputs to be different.

Reading A+BA + B as ordinary addition and writing 1+1=21 + 1 = 2

Why it's wrong: In gate notation ++ means OR, and the output of a gate can only be 0 or 1.

Correct: With gates, 1+1=11 + 1 = 1 (OR). The value 2 only appears when you add binary numbers, and then it is written as 1010 with a carry digit.

Treating NAND as NOT A AND NOT B, that is A‾⋅B‾\overline{A} \cdot \overline{B}

Why it's wrong: NAND flips the output of AND, not the inputs. For A=1A = 1, B=0B = 0: NAND gives 1⋅0‾=1\overline{1 \cdot 0} = 1, but 1‾⋅0‾=0⋅1=0\overline{1} \cdot \overline{0} = 0 \cdot 1 = 0.

Correct: NAND =A⋅B‾= \overline{A \cdot B}: first AND, then NOT. The bar covers the whole product.

Feeding the original inputs into the last gate of a circuit

Why it's wrong: In a circuit each gate only receives the wires connected to it. The last gate usually gets the outputs of earlier gates, not A, B and C.

Correct: Work from the inputs to the output, write the output of every gate next to it, and use those values for the next gate.

Why It Matters

Every digital device you own is built from logic gates:
  • Computer chips: a processor contains billions of transistors wired together as gates, and everything it does (adding, comparing, storing) comes down to AND, OR and NOT on 1s and 0s
  • Adding numbers: two gates, an XOR and an AND, are enough to add two binary digits, and chains of such circuits add whole numbers
  • Alarms and safety systems: an alarm rings when it is armed AND a door OR a window is open
  • Cars and machines: a seat belt warning lights up when the engine is on AND the belt is NOT fastened; a press only works when both hands push two buttons (AND)
  • Lights at home: a light that can be switched from two places (stairs, hallway) is an XOR circuit
In the previous lessons you wrote Boolean expressions on paper. Logic gates are the same expressions built in hardware, so learning to read a circuit is learning to read the language of computers.

Real World Applications

Alarm Systems

A home alarm is a small logic circuit: sensors give 1 or 0, gates decide whether the siren gets 1.

Example:

With armed switch AA, door sensor DD and window sensor WW, the alarm rings when Y=A∧(D∨W)=1Y = A \land (D \lor W) = 1.

1Try It Yourself

An alarm uses Y=A∧(D∨W)Y = A \land (D \lor W): A=1A = 1 when the system is armed, D=1D = 1 when the door is open, W=1W = 1 when the window is open.

In how many of all possible input combinations does the alarm ring?

Step 1: Write the mathematical expression

Write the number of input combinations as a power of 2:

Adding Numbers in a Chip

Every addition a computer does is built from half adders and full adders made of gates.

Example:

A half adder computes the sum digit S=A⊕BS = A \oplus B and the carry digit C=A∧BC = A \land B of two binary digits.

2Try It Yourself

A half adder gets the inputs A=1A = 1 and B=1B = 1. It outputs S=A⊕BS = A \oplus B and C=A∧BC = A \land B, and the result is read as the binary number CSCS.

What are S and C, and which ordinary number does the result stand for?

Step 1: Write the mathematical expression

Write the addition the circuit performs:

Building Chips from NAND Gates

Chip makers like NAND gates because every other gate can be built from NAND gates alone.

Example:

Connect both inputs of a NAND gate to the same signal AA: the output is A⋅A‾=A‾\overline{A \cdot A} = \overline{A}, so it works as a NOT gate.

3Try It Yourself

A small chip package holds 4 NAND gates. A NOT gate needs 1 NAND gate, and an AND gate needs 2 (a NAND followed by a NAND used as NOT). A designer needs 3 AND gates and 2 NOT gates.

How many NAND gates and how many chip packages does the designer need?

Step 1: Write the mathematical expression

Write the number of NAND gates as one calculation:

Key Takeaways

  • 1A logic gate takes inputs that are 1 (voltage on) or 0 (voltage off) and gives one output, also 1 or 0
  • 2AND gives 1 only when both inputs are 1; OR gives 1 when at least one input is 1; NOT flips its single input
  • 3XOR gives 1 when the inputs are different; NAND and NOR are the opposites of AND and OR
  • 4Gate notation: A⋅BA \cdot B (AND), A+BA + B (OR), A‾\overline{A} (NOT), A⊕BA \oplus B (XOR), and here 1+1=11 + 1 = 1
  • 5To find the output of a circuit, go from the inputs to the output and write down the output of every gate
  • 6Name each gate's output as an expression to get the Boolean expression of the whole circuit

Frequently Asked Questions

Why do gates use 1 and 0 instead of true and false?

Inside a chip there are only voltages. A high voltage stands for 1 (true) and a low voltage for 0 (false). Using just two levels makes circuits fast and reliable, because a signal that is a little weaker still clearly reads as 1.

What is the difference between OR and XOR?

They differ in only one row: when both inputs are 1. OR gives 11 (at least one is on), XOR gives 00 (the inputs are not different). XOR is the either-or-but-not-both gate.

Why are NAND gates so popular?

Any other gate can be built from NAND gates alone. For example, a NAND with both inputs joined is a NOT gate. So a factory can make chips from one kind of gate. You will see the algebra behind this in the Boolean Algebra lesson.

Can I check gates with ordinary arithmetic?

Yes, with 0 and 1: AND is A×BA \times B, NOT is 1−A1 - A, OR is A+B−A×BA + B - A \times B and XOR is A+B−2×A×BA + B - 2 \times A \times B. For example, OR for 1,11, 1 is 1+1−1=11 + 1 - 1 = 1. Try it in the calculator.

Glossary

Logic gate
An electronic circuit that performs one Boolean operation on inputs of 1 and 0
Input / output
The signals going into a gate and the single signal coming out of it
Circuit
Gates connected by wires, where the output of one gate is an input of another
Inverter
Another name for the NOT gate, which flips 1 to 0 and 0 to 1
XOR (exclusive OR)
A gate whose output is 1 when its inputs are different, written A⊕BA \oplus B
Half adder
A circuit of one XOR and one AND gate that adds two binary digits: S=A⊕BS = A \oplus B, C=A∧BC = A \land B

Formula Card

AND

Y=A⋅B=A∧BY = A \cdot B = A \land B

1 only when both inputs are 1

OR

Y=A+B=A∨BY = A + B = A \lor B

1 when at least one input is 1

NOT

Y=A‾=¬AY = \overline{A} = \neg A

Flips the input

XOR

Y=A⊕BY = A \oplus B

1 when the inputs are different

NAND

Y=A⋅B‾Y = \overline{A \cdot B}

Opposite of AND: 0 only when both inputs are 1

NOR

Y=A+B‾Y = \overline{A + B}

Opposite of OR: 1 only when both inputs are 0

More in This Topic