From microscopic transistors to complex digital circuits: how computers make instant decisions.
A modern CPU contains billions of microscopic electronic switches called transistors. They turn on (1) or off (0).
Transistors are wired together to form logic gates that perform fundamental logical operations in hardware.
A bank vault door will unlock ONLY IF a valid Keycard is swiped AND a Fingerprint matches, OR if the Manager Emergency Key is turned.
Computers do not understand numbers or letters — they only process electrical signals.
0 Volts represents Off, False, No Signal, or Inactive Sensor.
5 Volts (or 3.3V) represents On, True, Active Signal, or Triggered Sensor.
Output is 1 (True) ONLY IF ALL inputs are 1.
Like a bank vault requiring BOTH keycard AND pin code. If either is missing (0), output stays 0.
| Input A | Input B | Output (A AND B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Output is 1 (True) if AT LEAST ONE input is 1.
Like a house burglar alarm: triggers if the Front Door sensor opens OR the Back Window sensor opens.
| Input A | Input B | Output (A OR B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Takes a single input and flips it to the opposite value.
If input is 1, output is 0. If input is 0, output is 1. Used to flip logic conditions in hardware.
| Input A | Output (NOT A) |
|---|---|
| 0 | 1 |
| 1 | 0 |
Adding an inverter (NOT) to the output of AND and OR creates universal logic gates.
Output is 0 ONLY when both inputs are 1. Used in flash memory chips (NAND SSDs)!
Output is 1 ONLY when both inputs are 0. Used in control systems.
Output is 1 IF AND ONLY IF inputs are DIFFERENT from each other.
Like a hallway light controlled by two stair switches: flipping either switch changes the light state!
| Input A | Input B | Output (A XOR B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| A | 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 |
Combining gates allows computers to calculate addition, subtraction, and branch decisions.
A = 1, B = 1 enter an AND Gate.
AND Gate outputs X = 1.
X = 1 enters a NOT Gate.
Z = 0 (NAND behavior!).
The alarm buzzer sounds IF the Engine is ON (1) AND the Seatbelt is NOT buckled (0).
Assuming standard OR means "one or the other, but not both" in computer science.
Standard OR outputs 1 when both inputs are 1. Only XOR outputs 0 when both are 1!
Input A: 1 | Input B: 0
1. Inputs A and B pass into an OR Gate → Output X.
2. Output X and Input C (0) pass into an AND Gate → Final Output Z.
A smart green-house system is supposed to open the window if Temperature > 30°C (1) AND Humidity > 80% (1).
The engineer used an OR Gate by accident!
Design a circuit logic that turns on streetlights when it is DARK (Night = 1) AND Motion is detected (Motion = 1), OR if Manual Override Switch is ON (1).
and, or, and not operators in code!Complete this truth table puzzle in your notebook:
If A = 0 and B = 1, find the output of:
1. A OR B = ___
2. NOT (A AND B) = ___