Logic gates
Flip switches into AND, OR, NOT, NAND, NOR and XOR gates, watch the truth table, then build circuits for alarms, lights and robots.
The activity
Playground
A logic gate takes signals that are either 1 (on) or 0 (off) and gives one signal out. Choose a gate and flip the switches: the lines carrying a 1 light up.
CHOOSE A GATE
AND. AND gives 1 only when every input is 1.
FLIP THE SWITCHES
A 0, B 0. AND gives 0, so the LED is off. Flip a switch to see what changes.
| A | B | Output (AND) | Set the switches |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
The highlighted row matches the switches. Every row together is the gate's whole rule: 4 rows for 2 inputs, because each switch doubles the combinations. Try predicting the output before you flip a switch.
Build the circuit
Each challenge is a rule from real life. Choose the gate for each empty slot, test it with the switches, then check it against every row. Three stars if it works on your first check.
CHALLENGES
Burglar alarm
The alarm should sound only when the system is armed and a door is open.
- A = 1
- The system is armed
- B = 1
- A door is open
- LED on
- The alarm sounds
SLOT 1
Choose a gate, test it with the switches, then check it against every row of the table.
| A | B | Should be | Set the switches |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
What you'll practise
- What AND, OR, NOT, NAND, NOR and XOR do
- Reading and checking truth tables
- Turning a real-world rule into a circuit
For teachers and parents
Ask learners to predict the LED before every flip, then check the truth table. The alarm challenges link to the Grade 8 Technology task of wiring a panic-button alarm with AND and OR gates.
In the curriculum
In South Africa's Coding and Robotics CAPS, which schools are phasing in from 2026 to 2032, Grade 8 and 9 learners build truth tables for NOT, OR and AND gates, with two inputs in Grade 8 and three in Grade 9; Electrical Technology adds NAND, NOR and XOR from Grade 10. Source (PDF)
Part of Teachist's Robotics and programming program
More robotics activities
ALL ACTIVITIES →See and do: picture games without words
16 picture games, each in six grade bands from Grade R to Grade 7, in maths, coding, science, life skills and geography that need no reading and no sound. A helper hand shows what to do.
Program a robot
Build a program from blocks to steer a robot through twelve mazes, then use loops and its sensor to do more with less.