Logic Gates
Where Logic Becomes Electricity
Boolean logic gives us AND, OR, and NOT as ideas. A logic gate is one of those ideas built out of electronics: a tiny circuit with input wires and an output wire, where a high voltage means 1 (true) and a low voltage means 0 (false).
Feed signals in, and the gate's output is computed by physics — no thinking required, no program running. This is the bottom layer of the whole tower of computing: underneath every app, every operating system, every algorithm, it is gates all the way down.
The Three Basic Gates
AND gate — two inputs, one output. Output is 1 only when both inputs are 1.
| A | B | output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Think of two switches in a line on the same wire: the light only comes on when both are closed.
OR gate — output is 1 when at least one input is 1.
| A | B | output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Two switches on parallel wires: either one completes the circuit.
NOT gate (inverter) — one input, one output, always opposite.
| A | output |
|---|---|
| 0 | 1 |
| 1 | 0 |
These truth tables are exactly the ones from Boolean logic — that is the point. The gate is the hardware embodiment of the operator.
Connecting Gates Into Circuits
A single gate is not very exciting. The power comes from chaining: one gate's output becomes another gate's input, building circuits that compute bigger expressions.
Design a burglar alarm that sounds when: (door opens OR window opens) AND alarm is armed.
door ────┐
OR ────┐
window ──┘ AND ──── siren
armed ──────────┘
Trace it with the door open (1), window shut (0), alarm armed (1): the OR gate sees 1,0 and outputs 1; the AND gate sees 1,1 and outputs 1 — siren on. Change armed to 0 and the AND outputs 0 — silent, however many windows swing open. Tracing signals through a circuit like this is the hardware version of tracing a flowchart.
Combinations are so useful they get their own names: AND followed by NOT is NAND, OR followed by NOT is NOR. Remarkably, NAND alone is universal — with enough NAND gates you can build AND, OR, NOT, and therefore any logic circuit whatsoever.
From Gates to Calculators
Here is the leap that made the modern world. Binary numbers are strings of 0s and 1s, and gates process 0s and 1s — so circuits can do arithmetic.
Adding two bits: 0+0=0, 0+1=1, 1+0=1, and 1+1=10 in binary (0, carry 1). Look at those two output columns: the "carry" column is exactly an AND gate, and the "sum" column is a simple gate combination too. That small circuit is called a half adder; chain adders together and you have a circuit that adds full binary numbers — the heart of every calculator and processor.
A modern processor chip packs billions of gates (each made from transistors — microscopic electronic switches) into an area smaller than a fingernail, switching billions of times per second. Every game, video, and message is ultimately that: unimaginable numbers of tiny AND, OR, and NOT operations, layered by abstraction until they look like a photo of your dog.
Try It Yourself
Describe these as gate circuits (then check with a truth table):
- A car warning chime sounds when the engine is running AND the seatbelt is NOT fastened
- A hallway light turns on when the motion sensor triggers OR the manual switch is on
- A vending machine dispenses when money inserted AND item selected AND NOT out-of-stock
Worked Example — Building an XOR Gate From Basic Gates
Not every useful gate is one of the three basics — some are built by combining AND, OR, and NOT. A common example is XOR (exclusive OR): output 1 when the inputs are different, and 0 when they're the same.
| A | B | XOR output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Compare this carefully with the plain OR table from earlier: OR outputs 1 for both inputs being 1, while XOR specifically outputs 0 there — "exclusive" OR excludes that case. XOR can be built entirely from the three basic gates: (A OR B) AND NOT(A AND B) — in words, "at least one is on, but not both". Trace it with A=1, B=1: (1 OR 1) is 1, (1 AND 1) is 1, NOT 1 is 0, and 1 AND 0 is 0 — matching the table exactly. This is the same lesson as functions calling functions: a small circuit becomes a trusted building block, and bigger circuits are built by combining trusted building blocks rather than starting from raw wires every time.
From Gates to Memory: Why a Computer Can Remember Anything At All
There is a puzzle worth sitting with: gates compute an output instantly from their current inputs — remove the inputs and the output vanishes with them. So how does a computer store a bit, keeping a value even after the inputs that created it are gone? The answer is one of the cleverest tricks in this course: feed a gate's output back into its own input, in a loop. A circuit built from two NOR gates wired so each one's output feeds the other's input can be nudged into one of two stable states — and it will hold that state indefinitely, even though no single gate is "storing" anything by itself. This circuit, called a latch, is the ancestor of every memory cell in every byte of RAM in every computer ever built — proof that the entire tower of computing, right up to a spreadsheet remembering last week's numbers, rests on nothing more exotic than AND, OR, and NOT, wired together in the right shape.
Key Words
- Logic gate — an electronic circuit performing a Boolean operation on input signals
- Truth table — a table giving a gate or circuit's output for every input combination
- Inverter — another name for the NOT gate
- NAND / NOR — AND or OR followed by NOT; NAND alone can build any circuit
- Transistor — the microscopic electronic switch from which gates are built