Logic Gates Truth Table
Flip the switches, watch the electrons flow. The ultimate interactive guide to Digital Logic Design and Boolean Algebra.
Logic Lab
Select a gate to test its circuit.
AND Gate
Logic GateOutput is ON only if ALL inputs are ON.
How to use
- 1Click the Input Switches (Input A/B) above to toggle them ON/OFF.
- 2Watch the wires light up green when electricity flows.
- 3Observer the Truth Table on the right highlighting the active rule.
Live Truth Table
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The Atoms of Computing
Every movie you stream, every message you send, and every game you play is ultimately just billions of Logic Gates turning ON and OFF.
A Logic Gate is a simple physical device that makes a decision. It takes one or more inputs (electricity: ON or OFF) and produces a single output based on a strict rule. By connecting millions of these simple decision-makers together, we create the complex intelligence of a CPU.
Binary: The Language of Gates
Computers don't understand English or Decimal numbers. They only understand State.
- 1TRUE / High Voltage (5V) / ON
- 0FALSE / Low Voltage (0V) / OFF
The Universal Gate: NAND
You might think AND or OR are the most important gates, but NAND is the king of manufacturing.
It is mathematically proven that you can build ANY other logic gate using only NAND gates. Because of this property, manufacturers like Intel and Samsung fill chips with billions of identical NAND gates to save cost.
Common Logic Gates Explained
AND Gate
The "Strict" Gate. It's like a dual-key security system. The vault opens ONLY if Key A AND Key B are turned.
OR Gate
The "Friendly" Gate. It's like a hallway with two light switches. If Switch A OR Switch B is flipped, the light turns on.
XOR Gate (Exclusive OR)
The "Difference" Detector. It outputs ON if the inputs are different. It is the fundamental component of a Binary Adder (calculating 1+0=1, but 1+1=0 with a carry).
From Gates to Processors
How do we get from AND/OR to playing Fortnite?
1. Gates connect to form Adders (Math).
2. Adders connect to form an ALU (Arithmetic Logic Unit).
3. The ALU connects to Memory Registers to form a CPU.
It's just layers of abstraction on top of simple switches!
Frequently Asked Questions
What are the 7 basic logic gates?
The 7 fundamental logic gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR. These building blocks can be combined to create any possible digital circuit, from a simple alarm to a supercomputer processor.
Why is NAND called a Universal Gate?
NAND is called a "Universal Gate" because you can create ANY other gate (AND, OR, NOT, etc.) using only a combination of NAND gates. This is why SSDs and Flash memory are built almost entirely out of NAND cells - it's cheaper to manufacture just one type of component.
What is the output of XOR?
XOR (Exclusive OR) outputs 1 (True) only if the connected inputs are DIFFERENT. If inputs are (0,1) or (1,0), output is 1. If inputs are (0,0) or (1,1), output is 0. This is crucial for binary addition.
What acts as a logic gate in a computer?
Transistors! Specifically, MOSFET transistors are used as tiny electronic switches. By arranging transistors in specific patterns (like CMOS technology), we create physical hardware that behaves exactly like these mathematical logic gates.
What is a Truth Table?
A Truth Table is a mathematical table used in logic to compute the functional values of logical expressions. It lists every possible combination of input values (0s and 1s) and the resulting output for the gate.
Difference between OR and XOR?
OR (Inclusive OR) outputs True if one OR both inputs are True. XOR (Exclusive OR) outputs True ONLY if one is True, but NOT both. In plain English: OR is "Coffee or Tea (or both)". XOR is "Soup or Salad (not both)".
What is Boolean Algebra?
Boolean Algebra is a branch of algebra where values are true (1) or false (0), instead of numbers. It uses operators like AND (multiplication), OR (addition), and NOT (negation) to solve logic problems.
How does a NOT gate work?
A NOT gate (Inverter) simply flips the bit. If 0 goes in, 1 comes out. If 1 goes in, 0 comes out. It requires only a single input.
What is De Morgan's Law?
De Morgan's laws describe how NOT interacts with AND/OR. Specifically: NOT (A AND B) = (NOT A) OR (NOT B). This rule is essential for simplifying complex digital circuits to make them cheaper and faster.
What is the difference between TTL and CMOS?
TTL (Transistor-Transistor Logic) uses BJTs (Bipolar Junction Transistors) and consumes more power. CMOS (Complementary Metal-Oxide-Semiconductor) uses MOSFETs and consumes very little power when static, which is why all modern CPUs use CMOS.
What happens if I leave an input floating?
In real hardware, a "floating" input (not connected to 0 or 1) acts like an antenna and randomly picks up noise, causing the output to flicker unpredictably. Always use "pull-up" or "pull-down" resistors to define a default state.
What is a Half Adder?
A Half Adder is a simple circuit made of an XOR gate and an AND gate. It can add two single binary digits together, producing a Sum (XOR) and a Carry (AND).
Can logic gates deal with 3 inputs?
Yes! A 3-input AND gate outputs 1 only if all three inputs are 1. A 3-input OR gate outputs 1 if at least one of the three inputs is 1.
What represents 0 and 1 in voltage?
In standard 5V logic (TTL), 0V to 0.8V is considered "0" (Low), and 2V to 5V is considered "1" (High). The gap in between is undefined/noise margin.
What is a Buffer gate?
A Buffer outputs exactly what it inputs (0->0, 1->1). It is used not for logic, but to amplify a signal's strength so it can drive more components (fan-out) without signal degradation.