Mansori

Logic Gates: AND, OR, NOT

About this lesson, for parents and teachers

Deep inside every computer chip are billions of tiny decision makers called logic gates. Each one is a simple rule about 1s and 0s. Flip the switches and figure out each rule.

Ages 9–11 · about 8 minutes · builds on If/Else: Run the Traffic Lights · leads to Build an Adder From Logic Gates

Try this

  1. Tap switch A and switch B. Watch the current flow along the wires and see if the lamp lights.
  2. Tap each ? in the lamp column to predict 0 (off) or 1 (on) for that row.
  3. Press Check. The circuit tests every row and marks your predictions green or red.
  4. Finish AND, OR and NOT, then a circuit with two gates chained together.

How it works

Computers think in 1 (true, on) and 0 (false, off). A logic gate takes one or two of these as inputs and gives one output. In real chips, the inputs and outputs are wires that either carry electricity or not. Each gate is made from tiny switches called transistors, and a modern chip holds billions of them.

An AND gate outputs 1 only when input A and input B are both 1. An OR gate outputs 1 when A or B is 1, including when both are. A NOT gate has one input and flips it: 1 becomes 0 and 0 becomes 1. These three gates are enough to build every other kind of logic circuit.

The table with every possible input and its output is called a truth table. Two inputs can only be 00, 01, 10 or 11, so the table has 4 rows. Filling in a truth table is how engineers check that a circuit does what they want before they build it.

Gates can be chained: the output of one gate becomes the input of the next. In A AND NOT B, B is flipped first, so the lamp lights only when A is 1 and B is 0. By chaining thousands of gates, engineers build circuits that add numbers, compare them and remember them. That is what a processor is made of.

Where engineers use this

Every processor in a phone, game console or laptop is built from billions of transistors wired as logic gates. Programmers use the same AND, OR and NOT in code, like: if the player has a key AND the door is closed, open the door.

Words to know

Logic gate
A tiny circuit that takes 1s and 0s as inputs and gives one 1 or 0 as output by a fixed rule.
Boolean
A value that can only be true (1) or false (0), named after mathematician George Boole.
Truth table
A table listing every combination of inputs and the output for each one.
Input and output
What goes into a gate (the switches) and what comes out (the lamp).

Talk about it

Goal: Flip switches into AND, OR and NOT gates and predict when the lamp lights up.

  • Can you think of a real rule that uses AND? For example: you can go outside if your homework is done AND it is not raining.
  • When is an OR rule kinder than an AND rule?
  • What happens if you put two NOT gates in a row?

Without a screen: Make a hallway light game: two people hold cards that say 1 or 0. A third person is the gate and holds up a flashlight only by the rule written on a card (AND, OR or NOT). Switch roles and gates. Then try writing out the 4-row truth table on paper together.

Curriculum links: CSTA K-12 1B-CS-02 (model how computer hardware and software work together); Boolean logic foundations for AP Computer Science Principles AAP-2.E and AAP-2.F

Questions

What are logic gates in simple words?
Logic gates are tiny circuits that make simple decisions with 1s and 0s. An AND gate says yes only if both inputs say yes, an OR gate says yes if either does, and a NOT gate flips the answer.

What is the difference between AND and OR?
AND needs both inputs to be 1 to output 1. OR needs at least one input to be 1. So for inputs 1 and 0, AND gives 0 but OR gives 1.

How do logic gates make a computer work?
When you connect many gates, the output of one feeds the next. Groups of gates can add binary numbers, compare values and store bits, and billions of them together form a processor.