Lesson 1: Logic Gates (The Foundation)
Logic gates are the physical realization of Boolean functions. They take one or more binary
inputs and produce a single binary output.
AND Gate: Output is 1 only if all inputs are 1.
OR Gate: Output is 1 if at least one input is 1.
NOT Gate (Inverter): Flips the input (1 becomes 0, 0 becomes 1).
NAND & NOR: The "Universal Gates." You can build any other gate using only these.
XOR (Exclusive OR): Output is 1 if the inputs are different.
Input A Input B AND (A·B) OR (A+B) XOR (A⊕B)
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
If you were to peel back the layers of your smartphone, laptop, or even a digital microwave, you
wouldn't find miniature gears or tiny clerks filing papers. You’d find billions of Logic Gates.
These are the fundamental building blocks of digital systems—the "nerve cells" of a computer.
In the digital world, we deal with Binary: 1 (True/High/On) and 0 (False/Low/Off). Logic gates
are physical devices (usually made of transistors) that take these binary signals, perform a
specific logical operation, and spit out a single result.
1. The Gatekeepers: Basic Gates
These are the three "primary colors" of digital logic. From these, everything else is built.
The AND Gate (The Perfectionist): Think of the AND gate as a strict parent. It only
says "Yes" (1) if all inputs are "Yes." If even one input is 0, the output is 0.
o Real-world analogy: A safety system on a machine that only starts if the "Power
On" switch is flipped AND the "Safety Guard" is closed.
The OR Gate (The Easy-Going Friend): The OR gate is much more relaxed. It outputs
a 1 if at least one of its inputs is 1. It only outputs a 0 if everything is turned off.
o Real-world analogy: A doorbell system that rings if the "Front Door" button is
pressed OR the "Back Door" button is pressed.
The NOT Gate (The Contrarian): Also known as an Inverter. It only has one input and
one output. Whatever you give it, it gives you the opposite. Input 1? Output 0. Input 0?
Output 1.
2. The Heavy Lifters: Universal Gates (NAND & NOR)
In the engineering world, we love efficiency. NAND (NOT-AND) and NOR (NOT-OR) are
"Universal Gates." This means you can create any other logic gate—AND, OR, XOR, you name
it—using only NAND gates or only NOR gates. This is why many computer chips are made
almost entirely of NAND gates; it's cheaper to mass-produce one type of gate.
NAND Gate: The exact opposite of an AND gate. It outputs a 0 only when all inputs are
1.
NOR Gate: The exact opposite of an OR gate. It outputs a 1 only when all inputs are 0.
Shutterstock
3. The Decision Makers: XOR and XNOR
These gates are slightly more sophisticated and are vital for arithmetic.
XOR (Exclusive OR): This gate is picky. It outputs a 1 only if the inputs are different. If
both are 0 or both are 1, it outputs 0.
o Math Use: This is the heart of binary addition (1 + 1 = 0, carry 1).
XNOR (Exclusive NOR): The "Equality" gate. It outputs a 1 only if the inputs are the
same (both 0 or both 1).
The Cheat Sheet: Truth Tables
A Truth Table is a mathematical table used to show all possible outcomes based on every
possible input combination. For a 2-input gate, there are four possible combinations ($2^2 = 4$).
Input A Input B AND OR XOR NAND NOR
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 1 0
1 1 1 1 0 0 0
From Theory to Silicon
When you buy a physical logic gate, you aren't buying a single component; you're buying an
Integrated Circuit (IC). A common example is the 7408 IC, which contains four independent
2-input AND gates in one small plastic package. Learning to read the "pinout" (which leg of the
chip does what) is the first step in actually building your own digital hardware.