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.
Class quiz
10 questions on Boolean Logic. Students join with a name, you see everyone's score.
For Teachers
- 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
- • 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)
- 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?
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).
also holds for gates
Remediation: Remind students that a gate output is a single wire that can only be on or off. Write (OR) next to (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.
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
- 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
- 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.
Lesson Content
Everything students see: definition, examples, common mistakes, applications. Tap to open.
Definition
- 1 = voltage on (high), which means true
- 0 = voltage off (low), which means false
| AND | OR | XOR | NAND | NOR | ||
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
- 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
Worked Examples
The inputs are and . Find the output of an AND, OR, XOR, NAND and NOR gate.
AND gate
AND needs both inputs to be 1, but → AND:
OR gate
OR needs at least one 1, and → OR:
XOR gate
The inputs and are different → XOR:
NAND gate
NAND is the opposite of AND: AND gave , so flip it → NAND:
NOR gate
NOR is the opposite of OR: OR gave , so flip it → NOR:
Answer: AND , OR , XOR , NAND , NOR . NAND and NOR are always the opposite of AND and OR.
Common Mistakes
Thinking an OR gate gives when both inputs are
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: . XOR: . Only XOR asks for the inputs to be different.
Reading as ordinary addition and writing
Why it's wrong: In gate notation means OR, and the output of a gate can only be 0 or 1.
Correct: With gates, (OR). The value 2 only appears when you add binary numbers, and then it is written as with a carry digit.
Treating NAND as NOT A AND NOT B, that is
Why it's wrong: NAND flips the output of AND, not the inputs. For , : NAND gives , but .
Correct: NAND : 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
- 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
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 , door sensor and window sensor , the alarm rings when .
An alarm uses : when the system is armed, when the door is open, 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 and the carry digit of two binary digits.
A half adder gets the inputs and . It outputs and , and the result is read as the binary number .
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 : the output is , so it works as a NOT gate.
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: (AND), (OR), (NOT), (XOR), and here
- 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?
What is the difference between OR and XOR?
Why are NAND gates so popular?
Can I check gates with ordinary arithmetic?
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
- Half adder
- A circuit of one XOR and one AND gate that adds two binary digits: ,
Formula Card
AND
1 only when both inputs are 1
OR
1 when at least one input is 1
NOT
Flips the input
XOR
1 when the inputs are different
NAND
Opposite of AND: 0 only when both inputs are 1
NOR
Opposite of OR: 1 only when both inputs are 0