Skip to content
ROBOTICS · GRADES 8–12 · 20 MIN

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

PART 1

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

AND

A 0, B 0. AND gives 0, so the LED is off. Flip a switch to see what changes.

Truth table for AND
ABOutput (AND)Set the switches
000NOW
010
100
111

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.

PART 2

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

0 OF 9 SOLVED · 0 OF 27 STARS

CHALLENGE 1 OF 9

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

SLOT 1

Choose a gate, test it with the switches, then check it against every row of the table.

What it should do
ABShould beSet the switches
000NOW
010
100
111

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