Every learner needs a browser with the logic gates sandbox open. It starts with two switches, an AND gate and a lamp.
Running the lesson
45 min- 5 min
Flip the switches together: when does the lamp light? Write the four cases on the board. That is a truth table.
- 10 min
Swap the AND gate for OR, then NOT. Learners predict each truth table before trying it.
- 10 min
XOR: the hallway light with a switch at each end. Who can build it?
- 15 min
Half adder: load the example. Why is the second lamp called the carry? Relate it to adding 1 + 1 in binary.
- 5 min
The logic gates exercise as a quick check, with a class link if you want the results.
Materials
One device with a current browser per learner or pair. The sandbox needs no account and no installation, and nothing is uploaded.
A projector, to show your own sandbox while you explain.
The logic gates exercise for the last five minutes. Unfold "Use it with a class" on its page and copy the class link before the lesson.
Optional: a printed empty truth table (four rows, columns A, B and X) for each learner.
Step by step
1. Switches and a lamp (5 minutes). Learners click switch A and switch B and watch lamp X. Ask: "When does the lamp light?" Collect the four combinations on the board as a table with the columns A, B and X. Point out that the sandbox fills in the same table on the right and highlights the row that is set right now.
2. OR and NOT (10 minutes). Learners first predict the truth table of OR on paper, then test it. To swap a gate, click the AND gate, press Delete (its wires go with it), add OR from the toolbar, then wire it up again: drag from a right-hand dot to an input dot, once for each switch and once from the gate to the lamp. NOT has only one input, so one switch is enough. Ask which everyday sentence matches each gate: "both", "at least one", "the opposite".
3. XOR (10 minutes). Tell the story of a hallway light with a switch at each end: flipping either switch changes the light. Learners find the gate whose truth table matches (XOR) and build it. Fast pairs try the challenge "XOR without XOR", which allows only AND, OR and NOT.
4. The half adder (15 minutes). Load "Half adder" from the Examples menu. Write 0 + 0, 0 + 1, 1 + 0 and 1 + 1 on the board and their answers in binary: 0, 1, 1 and 10. Learners flip the switches and compare: lamp X shows the last digit (the sum), lamp Y the digit that moves one place to the left (the carry), just as in written addition. XOR makes the sum, AND makes the carry.
5. Check (5 minutes). Learners open the class link and do the exercise. The class average per task in Class results shows what to repeat next lesson.
Questions to ask
Why does the truth table have four rows for two switches? How many for three?
Which gate would you use for "the alarm sounds if the door or the window is open"?
A NAND gate alone can build every other gate. Who can build NOT from a NAND?
Answers
Each switch has two states, so two switches give 2 × 2 = 4 combinations; three give 8.
OR: one open is enough.
Connect both inputs of the NAND to the same switch: 1 NAND 1 = 0 and 0 NAND 0 = 1.
Typical misconceptions
"OR means one or the other, not both." That is XOR. In logic, OR is also 1 when both inputs are 1. The truth table settles the argument quickly.
"The carry is an error." It is the normal second digit of 1 + 1 = 10 in binary, like the 1 you carry in 5 + 5 = 10.
Symbols. The sandbox draws gates as rectangles with &, ≥1, =1 and 1 inside (the IEC symbols used in many European schools). English-language textbooks often use the rounded American shapes instead. Both mean the same; show learners one example of each if your textbook uses the other style.
Differentiation
Easier: hand out the printed truth table and let learners fill it in while they flip the switches. Skip NOT in step 2 and come back to it in the next lesson.
Harder: the challenges "AND from NAND" and "Majority vote" in the sandbox. They check the whole truth table and say which input combination is still wrong.
Pairs: one learner predicts, the other builds and tests; swap roles for each gate.
Homework
Write the truth table for (A AND B) OR C, with all eight rows.
Design the alarm system: switch A arms it, B is a door sensor, C a window sensor. The siren sounds when the system is armed and the door or the window is open. Draw the circuit, or build it in the sandbox with the challenge "Alarm system" and send the Share link.
Homework solutions
1. X is 1 whenever C is 1, and also when A and B are both 1.
A | B | C | X |
|---|---|---|---|
0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 |
2. A AND (B OR C): one OR gate for the two sensors, then an AND gate with the arm switch. Two gates are enough. The siren sounds in three of the eight rows: A = 1 with B = 1, C = 1 or both.
