Ready-to-teach lab
Logic gates lab: truth tables from LEDs
In this logic gates lab two push buttons are the inputs A and B, three gates each light an LED, and students build every truth table by pressing buttons and writing down what they see.
The lesson
Objective and parts
By the end, students can
- Complete the truth tables for AND, XOR and NOT from observation.
- Explain why an input needs a pull-down resistor.
- Predict the table of NAND and check it by changing a gate.
Parts, already on the bench
- Two push buttons, A and B, each with a 10 k pull-down resistor
- An AND gate, an XOR gate and a NOT gate
- Three LEDs, one on each gate output
- A 5 V supply
Nothing to hand out or collect: the circuit opens built and wired.
Steps
What students do
Each step is short enough to read out. Students work in the simulator beside this page.
- Draw three empty truth tables: AND and XOR with four rows each, NOT with two.
- Open the lab and press Run. With no button pressed, note which LEDs are lit.
- Hold A alone, then B alone, then both, and fill in a row each time.
- Check the NOT table: its LED is lit until A is pressed.
- Click the AND gate and change its function to NAND. Predict the new table, then test it.
- Change it to OR and do the same.
Questions
Questions for students
Hand these out as they are. The expected answers are under the list, for you.
- With no button pressed, one LED is already on. Which one, and why?
- For which inputs is XOR different from OR?
- What would happen to an input if its 10 k pull-down resistor were removed?
- How does the NAND table compare with the AND table?
Answer key for the teacher
- The NOT gate. Its input A is 0, so its output is 1.
- Only when both are 1. OR gives 1; XOR gives 0, because XOR means one or the other but not both.
- With the button open the input would be connected to nothing. It floats, and the gate could read it as 0 or 1.
- Every output is the opposite: NAND is AND followed by NOT.
Go further
For students who finish early
- Use XOR and AND together as a half adder: XOR is the sum, AND is the carry.
- Build NOT from a NAND gate by joining its two inputs.
Your class
Give this lab to every student
Assign to my class puts this circuit on each student’s class page as a starter. They change their own copy and hand it in, and the work comes back to you in one list.
The class tools are free for 30 days for one class of up to 20 students, with no card. Opening and running the lab needs no account and stays free.
More labs
The other labs in the set
Ohm's lawCircuits. 40 min.Series and parallelCircuits. 45 min.Voltage dividerCircuits. 40 min.LED and resistorCircuits. 30 min.RC circuitElectronics. 50 min.Transistor switchElectronics. 45 min.Arduino blinkArduino. 35 min.Button and LEDArduino. 40 min.Traffic lightArduino. 45 min.Ultrasonic distanceArduino. 45 min.Servo sweepArduino. 40 min.All labsThe whole set on one page.