Harmony Virtual Lab

Digital Technologies · Logic gates and Boolean algebra

Logic gates and truth tables

Switch the inputs of AND, OR, NOT, NAND, NOR and XOR gates and build each truth table.

Start this experimentAll Digital Technologies experiments

Aim

To investigate the behaviour of the basic logic gates and construct their truth tables.

Apparatus

  • Logic gate ICs or a logic trainer board
  • Switches for the inputs
  • LED for the output
  • 5 V supply

Theory

A logic gate takes binary inputs (0 = off/low, 1 = on/high) and gives one binary output.

  • AND: output is 1 only when all inputs are 1.
  • OR: output is 1 when at least one input is 1.
  • NOT: output is the opposite of the input.
  • NAND and NOR are AND and OR followed by NOT.
  • XOR: output is 1 when the inputs are different.

Procedure

  1. Choose a gate.
  2. Set inputs A and B to 0 and 0 and note whether the lamp lights.
  3. Record the row, then try 0 1, 1 0 and 1 1.
  4. Repeat for every gate.
  5. In Results, check which truth tables are complete.

What you do in the virtual lab

Set up the apparatus on screen, take readings and record them in a table (Gate; A; B; Output; Boolean expression). Simulated instruments give slightly different readings each time, as real ones do. Finish with a short quiz; every answer is explained.

Teachers can set the experiment for a class, see each student’s results and use it as a WAEC- or NECO-style practical paper in exam practice.

Practice questions

  1. Which gate gives an output of 1 only when both inputs are 1?

    1. AND
    2. OR
    3. NOR
    4. XOR
    Show the answer

    A. AND AND needs every input to be 1.

  2. The output of a NAND gate with inputs A = 1 and B = 1 is

    1. 1
    2. 2
    3. 0
    4. undefined
    Show the answer

    C. 0 AND gives 1, and NAND inverts it to 0.

  3. An XOR gate gives 1 when

    1. both inputs are 0
    2. both inputs are 1
    3. the inputs are the same
    4. the inputs are different
    Show the answer

    D. the inputs are different Exclusive OR is true when exactly one input is 1.

Do the experiment and the full quiz

Related Digital Technologies experiments

  • Binary, octal and hexadecimalDigital Technologies · JSS 2 – SSS 1Flip eight bit-switches to see how computers store numbers, then hit target values in binary.
  • Programming a robot: sequence and loopsDigital Technologies · JSS 1 – SSS 1Write a program of moves and turns to steer a robot to its goal, then shorten it with a loop.
  • How strong is a password?Digital Technologies · JSS 1 – SSS 2Test made-up passwords, measure their strength in bits and see how long an attacker would need to guess them.
  • Spreadsheet formulas and functionsDigital Technologies · JSS 2 – SSS 2Use cell references, SUM, AVERAGE, MAX and IF to complete a shop sales record and a class result sheet.
  • Coding in PythonDigital Technologies · SSS 1 – SSS 3Write real Python – print, variables, loops and if statements – and have each program checked automatically.
  • Train a simple AIDigital Technologies · JSS 3 – SSS 3Teach a computer to tell ripe plantain from unripe by giving it labelled examples, then test how accurate it is.