Logic gates sandbox with truth tables and challenges

Build circuits from switches, gates and lamps in the browser, watch the signals flow and read the truth table as it fills in. Three example circuits and five challenges that check themselves.

Web toolLower secondary +2CC BY 4.0

What you will learn

  • Explain what AND, OR, NOT, NAND, NOR and XOR do
  • Derive a truth table from a circuit
  • Build a half adder and a majority vote
  • Show that NAND alone can build any gate

What it is

A drawing board for digital logic. Switches are inputs, lamps are outputs, and seven kinds of gate sit in between: AND, OR, NOT, NAND, NOR, XOR and XNOR.

  • Build: add parts from the toolbar, drag them into place, and drag from an output dot to an input dot to connect them. Click a switch to flip it.

  • See: wires that carry a 1 turn blue, lamps light up.

  • Read: the truth table lists every combination of the switches and marks the one that is set right now.

  • Solve: five challenges, from "AND from NAND" to an alarm system, check the whole truth table and say which input combination is still wrong.

Gates use the rectangular IEC symbols (&, ≥1, =1, 1) taught in many European schools, with the English name under each. A small circle on the output means "inverted": NAND, NOR, XNOR and NOT have one.

How to use it

To do this

Do this

Add a part

Click it in the toolbar, or drag it onto the board

Connect two parts

Drag from the dot on the right of one part to an input dot of another

Put a gate into an existing wire

Drop the gate on the wire

Flip a switch

Click it

Remove a part or wire

Click it, then press Delete or the small × next to it; double-click removes a wire at once

Start again

Clear, or pick a circuit from Examples

Switches are labelled A, B, C in the order you add them and lamps X, Y, Z. The truth table reads the switches in label order, with A as the left-hand column, and shows up to six switches (64 rows). A circuit that feeds its own output back into itself and never settles is flagged, and its rows show "?".

Examples and challenges

The Examples menu loads three finished circuits:

  • Half adder: adds two bits. XOR gives the sum, AND the carry.

  • XOR from four NANDs: proof that NAND alone is enough to build other gates.

  • 2-to-1 multiplexer: switch C chooses whether input A or input B reaches the lamp, the basic idea behind selecting data in a processor.

The Challenges panel sets up the switches and lamps for you and checks your circuit with Check my circuit:

  1. AND from NAND: only NAND gates allowed.

  2. XOR without XOR: only AND, OR and NOT allowed.

  3. Half adder: upper lamp X is the sum, lower lamp Y the carry.

  4. Majority vote: three switches; the lamp lights when at least two are on.

  5. Alarm system: A arms the system, B is a door sensor, C a window sensor.

If the check fails, it names the first input combination that is still wrong, such as "for A = 1, B = 1 the lamps should show 1". Lamps are compared from top to bottom, so in the half adder the sum lamp has to be the upper one.

Solutions to the first two challenges

AND from NAND (two gates). Connect A and B to the first NAND. Connect the output of that NAND to both inputs of a second NAND, which turns it into NOT. NOT (A NAND B) = A AND B.

XOR without XOR (four gates). A OR B in one gate, A AND B in a second, NOT after the AND, then an AND gate that combines the OR with the NOT. In words: "at least one, but not both".

Safe for school use

Everything happens in the page: no account, nothing uploaded, nothing stored. "Share" puts the circuit into the link itself, after the #, which never reaches a server. Opening a shared link only draws the circuit it describes. A learner can change a shared circuit freely; the original link stays as it was.

Classroom mode (the button above the board) hides the site header and footer and gives the board the whole width of the screen, so a circuit is easy to read on a projector; Esc leaves it. On a phone the board keeps a readable size and scrolls sideways (switch to Fit to see all of it at once), a touch on a part or a pin moves it, a touch on the empty board scrolls the page, and an active challenge is shown above the board.

Ideas for class

  1. Discover: start with the AND circuit that opens by default. Learners flip both switches and write down when the lamp lights. Then swap the gate for OR, XOR and NAND.

  2. Half adder: load the example, then ask why the second lamp is called the carry.

  3. Challenge race: pairs solve "XOR without XOR" and share their link with the class; compare how many gates each solution needs.

  4. Predict, then test: show a circuit from Examples without the truth table. Learners write the table on paper first, then compare it with the sandbox.

  5. Hand in a link: learners solve the alarm system and send the Share link as their answer. Opening it shows you their exact circuit.

The full 45-minute plan is in the introduction to logic gates, and the logic gates exercise checks the rules afterwards.

Common problems

  • The lamp never lights. Check that the gate's output is connected to the lamp, not only the switches to the gate.

  • A wire went to the wrong input. Dropping a new wire on an input that is already connected replaces the old wire.

  • "Use exactly the switches A, B". A challenge needs the labels it names. If you deleted a switch and added another, check the letters.

Reuse this material

CC BY 4.0

You may copy, adapt and share it, also commercially, as long as you credit ManyPI and link back.

"Logic gates sandbox with truth tables and challenges" by ManyPI (https://manypi.com/edu/logic-gates-sandbox), licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)