Logic gates and truth tables
About this app
Toggle inputs to AND, OR, NOT, XOR, NAND and NOR gates. Follow illuminated wires and truth tables, then combine gates into a half adder.
Gates as simple rules
A logic gate combines binary inputs into an output according to a fixed rule. AND gives 1 when both inputs are 1, OR when at least one is 1, XOR when exactly one is 1, and NOT inverts its input. NAND and NOR are the negations of AND and OR. A truth table lists the output for every input combination. NAND is functionally complete: any other circuit can be built from NAND gates alone. Combining XOR and AND gives a half adder, which adds two bits.
What the app shows
In the middle is the circuit with the gate symbol, two input switches A and B and an output LED Q. Wires glow when they carry a 1. Next to it you see the gate's rule in plain words and the complete truth table, whose current row follows along. In half-adder mode two LEDs show the sum S (XOR) and the carry C (AND). A legend sums up all gate rules.
Try it yourself
Pick a gate and click the inputs through all four combinations 0/0, 0/1, 1/0 and 1/1. Compare AND with NAND or OR with XOR and notice in which row the outputs differ. Then switch on the half adder and compute 1 + 1: sum 0, carry 1, which is 10 in binary.
Frequently asked questions
- What is the difference between OR and XOR?
- OR gives 1 when at least one input is 1, including when both are 1. XOR (exclusive or) gives 1 only when exactly one input is 1; for 1 and 1 it gives 0. That makes XOR the sum digit when adding two bits.
- Why is NAND a universal gate?
- NAND alone can build NOT (both inputs tied together), AND (NAND followed by NOT) and OR (NAND of the inverted inputs). Since every logical function can be composed from AND, OR and NOT, NAND is enough for any digital circuit.
- How does a half adder work?
- A half adder adds two bits A and B. The sum S is A XOR B and the carry C is A AND B. For 1 + 1 this gives S = 0 and C = 1, which is 10 in binary. Multi-bit numbers need full adders, which also take an incoming carry into account.
- Which gates can I try in the app?
- AND, OR, NOT, XOR, NAND and NOR, each with clickable inputs, glowing wires and a live truth table, plus a half-adder mode with sum and carry LEDs.
Subject: Computer science
More from Computer science
- Ackermann function
- Elevator simulator
- Binary workshop
- Binary versus linear search
- The Collatz problem
- Inside a CPU
- Swap the inside
- One frame in 16 milliseconds — how a game engine renders an image (3D)
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps