A logic gate is a tiny electronic circuit that turns one or more inputs into a single output, each either 1 (on) or 0 (off). There are 7 basic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR. A truth table lists the output for every input, and gates combined in circuits make every computer chip work.
Steps in this lab: 1 Meet the gates · 2 Combine · 3 Build · 4 Challenges

A logic gate is a small circuit that follows one fixed rule to turn its inputs into an output. Every input and output is either 1 (on, high voltage) or 0 (off, low voltage), so a gate works with yes-or-no answers.
Real gates are built from transistors, tiny switches on a chip. (source: Dive into Systems, 5.3 Logic Gates) A modern chip holds billions of them: Apple’s M3 chip has 25 billion transistors. (source: Apple Newsroom, 30 Oct 2023)
You already know the idea from daily life. A microwave runs only when the door is closed and Start is pressed; that rule is an AND gate. In the lab you can tap the door and the button and watch the same rule in a circuit and a truth table.
An AND gate gives an output of 1 only when all of its inputs are 1.
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 OFF |
| 0 | 1 | 0 OFF |
| 1 | 0 | 0 OFF |
| 1 | 1 | 1 ON |
Rule: Lamp = A AND B
Real life: A microwave runs only when the door is closed AND Start is pressed. If either one is missing, it stays off.
With two inputs there are 4 possible rows, and only 1 of them (1 and 1) turns the output on. AND gates can also have three or more inputs. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
An OR gate gives an output of 1 when at least one of its inputs is 1.
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 OFF |
| 0 | 1 | 1 ON |
| 1 | 0 | 1 ON |
| 1 | 1 | 1 ON |
Rule: Lamp = A OR B
Real life: A doorbell rings when the front button OR the back button is pressed. Pressing both still rings it.
OR is on in 3 of the 4 rows; it is off only when every input is 0. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
A NOT gate (also called an inverter) has one input and gives the opposite value: 1 becomes 0 and 0 becomes 1.
| A | Output |
|---|---|
| 0 | 1 ON |
| 1 | 0 OFF |
Rule: Lamp = NOT A
Real life: A night light glows when the room light is NOT on.
A one-input gate has only 2 rows in its truth table. The small circle on its symbol means “flip it”. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
A NAND gate (NOT AND) gives an output of 0 only when all of its inputs are 1; in every other case it gives 1.
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 ON |
| 0 | 1 | 1 ON |
| 1 | 0 | 1 ON |
| 1 | 1 | 0 OFF |
Rule: Lamp = NOT (A AND B)
Real life: A school bus warning light stays on unless the front door and the back door are both closed.
Its truth table is the exact opposite of AND: 3 of the 4 rows are ON. NAND is one of the two universal gates. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
A NOR gate (NOT OR) gives an output of 1 only when all of its inputs are 0.
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 ON |
| 0 | 1 | 0 OFF |
| 1 | 0 | 0 OFF |
| 1 | 1 | 0 OFF |
Rule: Lamp = NOT (A OR B)
Real life: An air conditioner runs only when neither the window NOR the door is open.
NOR is ON in just 1 of the 4 rows (0 and 0). Like NAND, it is a universal gate, and it can have more than two inputs. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
An XOR gate (exclusive OR) gives an output of 1 when its two inputs are different, and 0 when they are the same.
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 OFF |
| 0 | 1 | 1 ON |
| 1 | 0 | 1 ON |
| 1 | 1 | 0 OFF |
Rule: Lamp = A XOR B
Real life: A stair light with a switch at the bottom and one at the top: it is on when exactly one switch is up. Flip either switch and the light changes.
XOR is ON in 2 of the 4 rows: 0 and 1, or 1 and 0. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
An XNOR gate (exclusive NOR) gives an output of 1 when its two inputs are the same, and 0 when they are different.
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 ON |
| 0 | 1 | 0 OFF |
| 1 | 0 | 0 OFF |
| 1 | 1 | 1 ON |
Rule: Lamp = NOT (A XOR B)
Real life: A match light turns on when two players pick the same shape.
XNOR is the opposite of XOR: it is ON for 0 and 0, and for 1 and 1. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt))
A truth table is a chart that lists every possible set of inputs and the output a gate or circuit gives for each one.
Each new input doubles the rows. A two-input gate has 4 rows (00, 01, 10, 11) and a three-input gate has 8 rows. (source: Lessons In Electric Circuits, Vol. IV, ch. 3 (Kuphaldt)) In the lab, tap any row of the table to set the switches to that row.
The rows always go in counting order, like binary numbers: 00, 01, 10, 11. That way you never miss a case. To see how binary counting works, try the Binary Numbers Lab; to turn words into 0s and 1s, try the Binary Translator.
| Gate | Symbol | Rule | Output is 1 when… | Real-life example |
|---|---|---|---|---|
| AND | A AND B | all inputs are 1 | microwave | |
| OR | A OR B | at least one input is 1 | doorbell | |
| NOT | NOT A | the input is 0 | night light | |
| NAND | NOT (A AND B) | not all inputs are 1 | bus warning light | |
| NOR | NOT (A OR B) | all inputs are 0 | air conditioner | |
| XOR | A XOR B | the inputs are different | stair light | |
| XNOR | NOT (A XOR B) | the inputs are the same | match light |
A small circle on a symbol always means NOT. That is why NAND, NOR and XNOR look like AND, OR and XOR with a circle at the output. In the lab, tap that circle to switch between the pairs.
A logic gate works like a group of switches that decide whether current reaches the output. Two switches in a row (series) make AND: the lamp lights only if both are closed. Two switches side by side (parallel) make OR: either one lights it. You can try both kinds of wiring in the series and parallel circuits lab.
Inside a chip, the switches are transistors, so a gate needs no moving parts. (source: Dive into Systems, 5.3 Logic Gates) The math behind it is Boolean algebra, which works with just two symbols, 1 and 0. Claude Shannon showed in his MIT master’s thesis that this algebra can describe switching circuits; it became the base of digital circuit design. (source: MIT News, 2001)
You combine logic gates by wiring the output of one gate into an input of the next, so the circuit follows a longer rule.
A home alarm should sound when it is armed (A) AND the door (B) OR the window (C) is open. That rule needs two gates: Alarm = A AND (B OR C). Work it out one gate at a time:
B OR C is 1 if the door or the window is open.| A armed | B door open | C window open | B OR C | Alarm |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 OFF |
| 0 | 0 | 1 | 1 | 0 OFF |
| 0 | 1 | 0 | 1 | 0 OFF |
| 0 | 1 | 1 | 1 | 0 OFF |
| 1 | 0 | 0 | 0 | 0 OFF |
| 1 | 0 | 1 | 1 | 1 ON |
| 1 | 1 | 0 | 1 | 1 ON |
| 1 | 1 | 1 | 1 | 1 ON |
Result: the alarm sounds in 3 of the 8 rows, all of them with A = 1. Disarmed (A = 0), it stays quiet whatever the door does. Open the home alarm in the lab → The same step also shows XOR built from AND, OR and NOT, and two gates that add 1 + 1 = 10 in binary.
A logic circuit is a set of gates wired so that switches go in on the left and lamps come out on the right.
In the Build step you get 2 or 3 switches, up to 6 gates in 3 columns and 1 or 2 lamps. Tap a gate, tap a free place, then tap an output dot and an input dot to draw a wire. Wires always run left to right, so a loop cannot form. An input with no wire shows “not connected”, never a silent 0. The truth table of your circuit fills in as you wire, and you can save a finished circuit as a block.
The universal gates are NAND and NOR: with enough of either one alone, you can build every other gate.
“NAND and NOR gates possess a special property: they are universal.”
With NAND gates only, NOT takes 1 gate (feed the same input into both inputs), AND takes 2, OR takes 3 and XOR takes 4. A NAND gate by itself is enough to make any logic circuit. (source: Dive into Systems, 5.3 Logic Gates)
A logic-gate challenge asks you to work backward from a truth table to the gates that make it.
Every answer is checked against the full truth table, so any correct circuit counts. Your done marks stay on this device. Open the challenges →
AND is written as a dot or no sign: A·B or AB. OR is a plus: A + B. NOT is a bar over the letter (A̅) or a prime: A′. XOR is A ⊕ B. So the home alarm is A·(B + C).
De Morgan’s laws say that NOT (A AND B) = (NOT A) OR (NOT B) and NOT (A OR B) = (NOT A) AND (NOT B). So a NAND gate gives the same table as an OR gate with a NOT on each input. Check it in the lab: build NOT A, NOT B and OR them, then compare with the NAND table.
| A | B | NOT (A AND B) | (NOT A) OR (NOT B) |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
AND, OR and NOT together can build any circuit. (source: Dive into Systems, 5.3 Logic Gates) NAND can make NOT (tie both inputs together), AND (NAND then NOT) and OR (NOT each input, then NAND). Since it makes all three, it makes everything. NOR works the same way with the roles of AND and OR swapped.
An XOR with more than two inputs gives 1 when an odd number of inputs are 1. This “parity” rule is used to spot errors in stored data.
Besides the curved shapes used here, a second standard draws every gate as a rectangle with a sign inside: & for AND, ≥1 for OR, =1 for XOR and 1 for a NOT (buffer box with a circle). Both mean the same thing.
Quantum computers use a very different kind of gate that works on qubits; see the Bloch sphere and qubits lab.
There are 7 basic logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR. NOT has one input; the other six usually have two inputs, and AND, OR, NAND and NOR are also made with three or more inputs (XOR and XNOR can be too).
Key takeaway: Seven basic gates.Yes. AND, OR, NAND and NOR gates can have three or more inputs. A three-input AND gives 1 only when all three inputs are 1, and its truth table has 8 rows instead of 4.
Key takeaway: Yes: 3 inputs means 8 rows.Because you can build every other gate from NAND gates alone, or from NOR gates alone. For example, NOT takes 1 NAND gate, AND takes 2 and OR takes 3.
Key takeaway: NAND alone (or NOR alone) can make any gate.OR gives 1 when at least one input is 1, including when both are 1. XOR gives 1 only when exactly one input is 1, so for 1 and 1 OR gives 1 but XOR gives 0.
Key takeaway: They differ only in the 1 and 1 row.Logic gates make every digital device work: phones, computers, game consoles, traffic lights and microwaves. A processor chip uses billions of transistors wired as gates to add numbers, compare them and store data.
Key takeaway: Every digital device is built from gates.Level: grades 6–8 first (Steps 1–2), grades 9–12 for Build, Challenges and “Go deeper”. Time: one 45-minute lesson, or two with the challenges.
Common mix-ups: OR is not “one or the other but not both” (that is XOR); the small circle means NOT; a wire that is not connected is unknown, not 0; rows of a truth table go in binary counting order.
Standards: in the CSTA K–12 Computer Science Standards (2017), the one standard that names logic is 3B-CS-02 (grades 11–12): “Illustrate ways computing systems implement logic, input, and output through hardware components.” (source: CSTA K–12 Computer Science Standards, revised 2017) For grades 6–8 the lab is enrichment that builds toward it.
Next lab: chain these gates into a 4-bit calculator in the Full Adder Simulator. Related labs: series and parallel circuits, qubits and the Bloch sphere, binary numbers, the binary translator and binary search.