TactivergeLite

Lite / Discovering How the World Works / Week 16

AND, OR, NOT: the three little deciders

A factory press only slams down if the worker has BOTH hands on the buttons. How does a machine check 'both'?

About 25 min · 3 goals · Reviewed by the founders' mentors · Full interactive version

Why should I care?

Every decision inside a computer, from 'is the door shut?' to 'should the airbag fire?', is built from tiny logic gates. Three of them, AND, OR and NOT, are enough to build any decision at all.

Predict

A doorbell has a front button and a back button. Either one should ring it. Which rule is that?

  1. Ring if front AND back are pressed
  2. Ring if front OR back is pressed
  3. Ring if NOT front is pressed
Guess first, then reveal

OR. The bell rings if at least one button is pressed (and it still rings if both are). An AND bell would only ring when two visitors pressed both buttons at once.

Discover

Pick AND. Before flipping anything, predict the output for all four input combinations. Then check them. Do the same for OR and NOT. Which gate gives 1 most often?

What the interactive shows (text version)

The logic gate diagram lets you choose AND, OR, NOT, NAND, NOR or XOR, flip inputs A and B between 0 and 1, and see the output lamp. A truth table lists every input combination with its output and highlights the current row. AND gives 1 only for 1,1; OR gives 0 only for 0,0; NOT flips its one input.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch for the truth tables of AND, OR and NOT, then pause before each one and predict it.

Introduces AND, OR, NOT and XOR, the building blocks behind every digital decision a computer makes.

“Boolean Logic & Logic Gates: Crash Course Computer Science #3” by CrashCourse (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Inputs and outputs are bits

A logic gate takes one or two inputs, each 0 (off, false, no) or 1 (on, true, yes), and produces one output by following a fixed rule. In real circuits, 0 and 1 are low and high voltages; inside a lab simulation they are just numbers.

The three basic gates

Plus three useful extras

Amazingly, NAND on its own can be wired up to make every other gate.

Explain it another way

Intuitive

AND is a strict parent: 'You can go out if your homework is done AND your room is tidy.' OR is a relaxed parent: 'You can go out if your homework is done OR your room is tidy.' NOT is a contrarian who always says the opposite.

Technical

Boolean algebra writes AND as A·B, OR as A + B and NOT as Ā (or ¬A). Gates are built from transistors acting as switches: two in series behave like AND, two in parallel like OR.

Applied

A car's interior light uses OR (any door open → light on). A microwave uses AND (door shut AND start pressed → heat). A smoke alarm's test button and its sensor are combined with OR.

Worked example 1

A safe opens only if the right code is entered AND the key is turned. The code is right (1) but the key isn't turned (0). Does it open?

AND needs both to be 1. 1 AND 0 = 0, so the safe stays shut.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 2. A microwave heats only if the door is shut and you pressed start. Which gate?
Practice 3. A NOT gate's input is 1. What is its output?

Apply it

Find three rules in machines around you and write each as a gate, e.g. 'car alarm sounds if a door opens OR the glass breaks'. Then invent one rule that needs NOT.

Reflect

Which gate do you think a safety system uses most often, and why?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Running out of bits: overflowTruth tables: checking every possibility →