Logic gates: switches that can add
See how a transistor works as a tiny switch, how a few of them make NOT, AND and OR gates, and how two gates together add 1 + 1.
Transistor
A switch with no moving parts, worked by electricity. A voltage on one wire, the input, lets current flow between two other wires, or stops it. So one bit can switch another bit, and that is all you need to build logic. A modern processor contains billions of transistors, each far smaller than a speck of dust.
A light switch needs your finger. A transistor's "finger" is another wire: put a 1 on it and current passes, put a 0 on it and it doesn't.
FOUR GATES
Gates: tiny circuits with one simple rule each
Wire a few transistors together and you get a logic gate: bits go in, one bit comes out, following a fixed rule. NOT flips its input: 0 becomes 1, 1 becomes 0. AND outputs 1 only if both inputs are 1. OR outputs 1 if at least one input is 1. XOR (exclusive or) outputs 1 if the inputs are different.
A car's inside light behaves like OR: it comes on if the driver's door is open or the passenger's door is open, or both. A two-key safe behaves like AND: it opens only if both keys are turned.
Check yourself
An AND gate gets the inputs 1 and 0. What does it output?
- 0
- 1
- 10
- It depends on the order of the inputs
Show the answer
0
Right. AND needs both inputs to be 1. One of them is 0, so the output is 0.
A B | AND OR XOR
0 0 | 0 0 0
0 1 | 0 1 1
1 0 | 0 1 1
1 1 | 1 1 0Two inputs give exactly four rows: 00, 01, 10 and 11. That's every possible case.This is a truth table: every input combination and what each gate outputs for it. Cover the AND column and try filling it in yourself: it's 1 only on the last row.
Check yourself
An OR gate with inputs 1 and 1 outputs 1.
Show the answer
True
True. OR outputs 1 if at least one input is 1, and here both are. The gate that gives 0 for 1 and 1 is XOR.
Step through it

A transistor is a switch A single transistor, drawn as a switch. Its input wire carries a 1, so current flows from the small power dot through to the lamp dot, which lights up. Put a 0 on the input and the lamp would go dark.

Same inputs, different rules Two gates side by side, each fed a 1 and a 0. The AND gate's output wire stays dim at 0, because it needs both inputs to be 1. The OR gate's output lights at 1, because one input being 1 is enough.

Wiring a half adder Now two input bits, A = 1 and B = 1, each split into two wires: one pair goes to an XOR gate and the other pair to an AND gate. The wires to both gates are lit. Those two gates wired to the same two bits are called a half adder.

1 + 1 = 10 The outputs appear. XOR gives the sum digit S = 0, because the inputs are the same. AND gives the carry C = 1, because both inputs are 1. Read carry then sum: 10, which is binary for two. One plus one, worked out by two gates.
Check yourself
In a half adder, which gate produces the carry bit?
- XOR
- AND
- OR
- NOT
Show the answer
AND
Right. You only carry when both bits are 1, and that is exactly AND's rule. XOR gives the sum digit.
From one bit to whole numbers: 5 + 3
- Write both numbers in binary
5 is 0101 and 3 is 0011. Line them up in columns, just like adding on paper.
- Rightmost column: 1 + 1
That's 10 in binary: write 0, carry 1 to the next column. Exactly what the half adder did.
- Next two columns: add the carry too
0 + 1 + carry 1 = 10, write 0, carry 1. Then 1 + 0 + carry 1 = 10, write 0, carry 1. A full adder is the circuit that also takes the carry coming in from the right.
- Last column and the answer
0 + 0 + carry 1 = 1. The result reads 1000, which is 8. Chain eight full adders and you can add two whole bytes the same way.
Check yourself
Match each gate to its rule
Show the answer
- NOT → Flips the input
- AND → 1 only if both inputs are 1
- OR → 1 if at least one input is 1
- XOR → 1 if the inputs are different
Check yourself
Add the columns like the adder does: 0110 + 0011 = ?
- 1001
- 0111
- 1011
- 1000
Show the answer
1001
Right. 0 + 1 = 1. 1 + 1 = 10, write 0 carry 1. 1 + 0 + 1 = 10, write 0 carry 1. 0 + 0 + 1 = 1. So 1001, which is 9: 6 + 3.
Lesson recap
- A transistor is a switch worked by electricity, so one bit can switch another; a processor has billions of them.
- Gates follow simple rules: NOT flips, AND needs both, OR needs at least one, XOR needs them different.
- Logic's OR gives 1 for 1 and 1; the "one but not both" gate is XOR.
- A half adder is an XOR gate (the sum digit) plus an AND gate (the carry): 1 + 1 = 10.
- Full adders chained together add whole numbers column by column, like addition on paper.