← Teacher guide

Why binary: logic gates

Students try every combination of two switches in a circuit to build AND and OR truth tables, use NOT, then add two bits with a half adder, to explain why digital systems are built on binary (AC9TDI8K04 node 3).

Data representation · Binary numbers · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 7 min · Worked example 10 min · Vary 10 min · Practise and Make 13 min

Before class

Try the boards yourself. A torch, a battery and two real switches (or a breadboard) make the Try concrete in a minute.

The one idea (the kit's chain for this node): electronic components have two reliable states → those states are 0 and 1 → gates combine them → so binary is the foundation of all computing. The half adder in Make shows gates doing the binary addition students know from lesson 5.

Simplifications: real gates are made of transistors, not mechanical switches; the circuit view is an analogy that holds for AND and OR.

Running the lesson

  1. Predict: students who chose "yes" picture parallel wiring. Ask them to trace the current.
  2. Try: have students fill a paper truth table as the board's fills.
  3. Worked example: before the OR line, ask what changes when the switches sit side by side.
  4. Vary: ask why AND has only one row that gives 1.
  5. Make: connect to 1 + 1 = 10 in binary and to carrying in base 10.

The hard part (on purpose)

Students read OR as everyday English (one or the other, not both). Point at the circuit: with both switches on, is there still a path for the current?

When students get stuck

What you will seeA question to askThe fix
A student writes 1 OR 1 = 0 (Sam's mistake).With both switches on side by side, can the current reach the lamp?Yes: OR means at least one. One but not both is XOR.
A student thinks gates add (1 AND 1 = 2).How many states can the output wire have?One bit: 0 or 1. Adding takes several gates, as in the half adder.

Answers to the checks

  1. two switches in a line: A battery, two switches and a lamp are wired in one loop, one switch after the other. Switch A is **on** and switch B is **off**. Does the lamp light?
    No. With the switches in a line, the current has to pass through both, so B being off breaks the loop. The lamp lights only when A AND B are on.
  2. Try: every combination: Click the switches to try all four combinations of A and B. When does the lamp light?

    Only when both switches are on: 1 AND 1 = 1. Every other row gives 0. That is an AND gate.
  3. Truth tables: Two switches side by side (an **OR** gate). A = 1 and B = 0. What is the output?
    1
    OR gives 1 when A or B is 1 (or both). A is 1, so the output is 1.
  4. Find the mistake: Sam fills in the OR gate's truth table. Click the line where it first goes wrong.
    line 5
    Line 5: OR gives 1 when at least one input is 1, so 1 OR 1 = 1. "One or the other but not both" is a different gate, XOR.
  5. Why binary?: Why are computers built on binary, not on ten levels for the digits 0 to 9?
    Switches have two states that are easy to tell apart, and gates can combine them to do any calculation
    Two states are reliable even with a noisy signal, and switches wired as gates (AND, OR, NOT) can be combined to add, compare and store anything.
  6. OR with one on: Switch the gate to OR. Turn on only A. What is the output?

    OR needs only one input on: 1 OR 0 = 1.
  7. OR with both on: Keep OR and turn B on too.

    1 OR 1 = 1: both on still counts as at least one.
  8. NOT: Switch to NOT. Turn A off. What comes out?

    NOT flips its one input: NOT 0 = 1.
  9. AND's one row: Switch back to AND and make the output 1.

    Only one row gives 1: A = 1 and B = 1.
  10. Does B matter?: An AND gate has A = 0. Does it matter what B is?
    No: the output is 0 whatever B is
    AND needs both. With A = 0, the output is 0 for either B.
  11. AND: What is **1 AND 0**?
    0
    AND gives 1 only when both are 1.
  12. NOT: What is **NOT 1**?
    0
    NOT flips 1 to 0.
  13. Alarm: A car alarm should sound if the door is opened **or** the window is broken. Which gate?
    OR
    Either input should set it off, so OR.
  14. Machine guard: A machine should run only when the guard is closed **and** the start button is pressed. Which gate?
    AND
    Both must be true: AND.
  15. Review: binary: Review: what number is **110** in binary?
    6
    110 = 4 + 2 = 6.
  16. add two bits: This circuit adds two bits: the sum is A XOR B and the carry is A AND B. Set the switches so the answer is 10 in binary (2).

    1 + 1 = 10 in binary: the sum bit is 0 and the carry is 1, just like 5 + 5 = 10 carries a 1 in base 10. Chains of these gates add numbers of any size.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: change the gate › OR with one on

Open task: any program that does what the step asks.

Vary: change the gate › OR with both on

Open task: any program that does what the step asks.

Vary: change the gate › NOT

Open task: any program that does what the step asks.

Vary: change the gate › AND's one row

Open task: any program that does what the step asks.

Vary: change the gate › Does B matter?

Open task: any program that does what the step asks.

add two bits

Open task: any program that does what the step asks.

Stretch and support

Stretch: A full adder adds three bits (two numbers and a carry in). Sketch how two half adders and an OR gate could make one.

Support: Keep the three truth tables on the board for the whole lesson.

Exit ticket

Fill in the output: 1 AND 1, 0 OR 1, NOT 0. Why are computers built on binary?

1, 1, 1. Switches have two reliable states, and gates combine them to do any calculation.

What each step is for

Where it leads

Next: Bits all the way down (tracing text and colours to binary).

Code links: and, or and not in Python and MakeCode conditions are these gates; the Robotics course uses them to combine sensor readings.