Logic Gates: The Fundamentals of Digital Electronics (AND, OR, NOT, NAND)

Logic gates are the basic building blocks of every digital circuit. They take one or more inputs that are either HIGH (1) or LOW (0), and give one output that depends on a fixed rule. Every computer, phone, calculator and digital watch is made of millions or billions of these gates. This guide explains the four most important gates, AND, OR, NOT and NAND, with symbols, truth tables, Boolean expressions, circuit diagrams, block diagrams and a detailed FAQ.

What Are Logic Gates?

A logic gate is an electronic circuit that performs a logical operation on binary inputs. Binary means only two states are used:

  • Logic 1: HIGH, ON, TRUE (for example, about +5 V or +3.3 V)
  • Logic 0: LOW, OFF, FALSE (about 0 V)

The output of a gate depends only on the present inputs. A circuit built only from gates, with no memory, is called combinational logic.

Block Diagram 1: A basic digital system

 ┌──────────┐     ┌──────────────────┐     ┌──────────┐
 │  INPUTS  │     │  LOGIC GATES     │     │ OUTPUTS  │
 │ switches │ ──► │  (AND, OR, NOT,  │ ──► │ LEDs,    │
 │ sensors  │     │   NAND ...)      │     │ buzzers, │
 │ signals  │     │  combinational   │     │ displays │
 └──────────┘     └──────────────────┘     └──────────┘

Digital Signals and Logic Levels

Digital circuits do not care about the exact voltage. They only care whether it is clearly HIGH or clearly LOW. The ranges below are for standard 5 V TTL (74LS series) chips.

LevelInput voltage acceptedTypical output voltage
Logic 0 (LOW)0 V to 0.8 V0 V to 0.4 V
Logic 1 (HIGH)2.0 V to 5 V2.4 V to 5 V
Undefined zone0.8 V to 2.0 VAvoid; output is unpredictable

CMOS chips (74HC and CD4000 series) use ranges based on the supply voltage, usually about 30% and 70% of VDD.

Boolean Algebra Basics

Boolean algebra is the mathematics of logic gates. Each gate has a Boolean expression.

OperationSymbol usedExampleRead as
AND· (dot)Y = A · BA AND B
OR+ (plus)Y = A + BA OR B
NOT‘ (prime) or barY = A’NOT A
NAND(A · B)’Y = (A · B)’NOT (A AND B)

The plus sign in Boolean algebra means OR, not addition. In Boolean algebra, 1 + 1 = 1.

1. AND Gate

Definition: The output is HIGH only when all inputs are HIGH. If any input is LOW, the output is LOW.

Boolean expression: Y = A · B

Easy way to remember: two switches in series controlling a lamp. The lamp lights only when both switches are closed.

Symbol (rectangular IEC style)

        ┌───────┐
 A ─────┤       │
        │  AND  ├───── Y = A · B
 B ─────┤       │
        └───────┘

Truth table: 2-input AND gate

ABY = A · B
000
010
100
111

Circuit 1: Diode AND gate

                    +5 V
                      │
                     [R] 1 kΩ
                      │
        ┌─────────────┴─────────────┬────► Y (output)
        │                           │
        ▼ D1                        ▼ D2
        ─                           ─
        │                           │
        A (input)                   B (input)

   (▼ = diode with anode at top, cathode at the input)

How it works: If either input is LOW (0 V), its diode conducts and pulls the output down to about 0.7 V (LOW). Only when both inputs are HIGH are both diodes switched off, and the resistor pulls the output up to +5 V (HIGH).

Common ICs: 74HC08 / 74LS08 (quad 2-input AND), CD4081.

2. OR Gate

Definition: The output is HIGH when at least one input is HIGH. The output is LOW only when all inputs are LOW.

Boolean expression: Y = A + B

Easy way to remember: two switches in parallel controlling a lamp. The lamp lights if either switch (or both) is closed.

Symbol

        ┌───────┐
 A ─────┤       │
        │  OR   ├───── Y = A + B
 B ─────┤       │
        └───────┘

Truth table: 2-input OR gate

ABY = A + B
000
011
101
111

Circuit 2: Diode OR gate

   A ────►|────┐
          D1   │
               ├───────┬────► Y (output)
   B ────►|────┘       │
          D2          [R] 10 kΩ
                       │
                      GND

How it works: If either input is HIGH, its diode conducts and pulls the output HIGH (about 0.7 V below the input voltage). The resistor to ground keeps the output LOW when both inputs are LOW.

Common ICs: 74HC32 / 74LS32 (quad 2-input OR), CD4071.

3. NOT Gate (Inverter)

Definition: The NOT gate has one input and one output. The output is the opposite (inverse) of the input.

Boolean expression: Y = A’ (also written as A with a bar over it)

Symbol (the small circle ○ means inversion)

        ┌───────┐
 A ─────┤  NOT  ○───── Y = A'
        └───────┘

Truth table: NOT gate

AY = A’
01
10

Circuit 3: Transistor NOT gate (inverter)

                 +5 V
                   │
                  [RC] 1 kΩ
                   │
                   ├────────────► Y (output)
                   │ C
                 │/
 A ──[RB 10 kΩ]─►│     Q1 (NPN transistor)
                 │\
                   │ E
                  GND

How it works:

  • Input LOW: the transistor is OFF, so no current flows through RC and the output is pulled up to about +5 V (HIGH).
  • Input HIGH: the transistor saturates and connects the output to ground, so the output is about 0.2 V (LOW).

Common ICs: 74HC04 / 74LS04 (hex inverter, 6 gates in one chip), CD4069.

4. NAND Gate

Definition: NAND means NOT-AND. The output is LOW only when all inputs are HIGH. In every other case, the output is HIGH. It is the exact opposite of the AND gate.

Boolean expression: Y = (A · B)’ = A’ + B’ (by De Morgan’s theorem)

Symbol

        ┌───────┐
 A ─────┤       │
        │ NAND  ○───── Y = (A · B)'
 B ─────┤       │
        └───────┘

Truth table: 2-input NAND gate

ABA · BY = (A · B)’
0001
0101
1001
1110

Block Diagram 2: NAND = AND followed by NOT

        ┌───────┐        ┌───────┐
 A ─────┤       │        │       │
        │  AND  ├── A·B ─┤  NOT  ○───── Y = (A·B)'
 B ─────┤       │        │       │
        └───────┘        └───────┘

Circuit 4: CMOS NAND gate (transistor level)

                  VDD (+)
              ┌─────┴─────┐
              │           │
         ┌────┴───┐  ┌────┴───┐
 A ──────┤ PMOS P1│  │ PMOS P2├────── B
         └────┬───┘  └────┬───┘
              └─────┬─────┘
                    ├──────────────► Y (output)
               ┌────┴───┐
 A ────────────┤ NMOS N1│
               └────┬───┘
               ┌────┴───┐
 B ────────────┤ NMOS N2│
               └────┬───┘
                    │
                   GND

How it works: The two PMOS transistors are in parallel (pull the output HIGH if either input is LOW). The two NMOS transistors are in series (pull the output LOW only when both inputs are HIGH). Only four transistors are needed, which is why NAND gates are small and fast.

Common ICs: 74HC00 / 74LS00 (quad 2-input NAND), CD4011.

Why NAND Is Called a Universal Gate

Any logic function can be built using only NAND gates. This is why NAND (and NOR) are called universal gates. Chip makers often build entire circuits from NAND gates alone.

Block Diagram 3: Building other gates from NAND gates

 NOT from NAND (join both inputs together):

 A ──┬──┐
     └──┤ NAND ○── A'
        └──────┘


 AND from NAND (NAND followed by NAND-as-NOT):

 A ──┤ NAND ○──┬──┤ NAND ○── Y = A · B
 B ──┘         └──┘


 OR from NAND (invert both inputs, then NAND):

 A ──┬──┤ NAND ○── A' ──┐
     └──┘                │
                         ├──┤ NAND ○── Y = A + B
 B ──┬──┤ NAND ○── B' ──┘
     └──┘
Gate to buildNAND gates needed
NOT1
AND2
OR3
NOR4

Summary Table of Logic Gates

GateBoolean expressionOutput is HIGH whenInputs
ANDY = A · BAll inputs are HIGH2 or more
ORY = A + BAt least one input is HIGH2 or more
NOTY = A’Input is LOW1
NANDY = (A · B)’At least one input is LOW2 or more
NORY = (A + B)’All inputs are LOW2 or more
XORY = A ⊕ BInputs are different2
XNORY = (A ⊕ B)’Inputs are the same2

Combined truth table for the four gates

ABANDORNANDNOT A
000011
010111
100110
111100

Gates with 3 or More Inputs

AND, OR and NAND gates can have more than two inputs. The rules stay the same:

  • 3-input AND: output is 1 only when A = B = C = 1 (1 row out of 8).
  • 3-input OR: output is 0 only when A = B = C = 0 (1 row out of 8).
  • 3-input NAND: output is 0 only when A = B = C = 1 (1 row out of 8).

The number of truth table rows is 2 raised to the number of inputs (2 inputs = 4 rows, 3 inputs = 8 rows, 4 inputs = 16 rows).

De Morgan’s Theorems

De Morgan’s theorems link AND, OR and NOT, and explain how NAND and NOR work:

  • Theorem 1: (A · B)’ = A’ + B’ (a NAND gate equals an OR gate with inverted inputs)
  • Theorem 2: (A + B)’ = A’ · B’ (a NOR gate equals an AND gate with inverted inputs)

Important Boolean Laws

LawAND formOR form
IdentityA · 1 = AA + 0 = A
NullA · 0 = 0A + 1 = 1
IdempotentA · A = AA + A = A
ComplementA · A’ = 0A + A’ = 1
CommutativeA · B = B · AA + B = B + A
Double negation(A’)’ = A(A’)’ = A

Worked Example: Door and Window Alarm

Problem: An alarm should sound when the system is armed and either the door or the window is opened.

Boolean expression: Alarm = (Door + Window) · Armed

Block Diagram 4: Alarm logic

 Door sensor   ──┐
                 ├──┤ OR  ├── (D + W) ──┐
 Window sensor ──┘                      ├──┤ AND ├──► Alarm buzzer
                                        │
 Armed switch  ─────────────────────────┘

Truth table

Door (D)Window (W)Armed (S)D + WAlarm = (D + W) · S
00000
00100
01010
01111
10010
10111
11010
11111

The alarm sounds only when Armed = 1 and at least one of Door or Window = 1.

Popular Logic Gate ICs

GateTTL / 74HC ICCMOS 4000 ICGates per chip
AND (2-input)7408CD40814
OR (2-input)7432CD40714
NOT (inverter)7404CD40696
NAND (2-input)7400CD40114
NOR (2-input)7402CD40014
XOR (2-input)7486CD40704

Real-World Applications of Logic Gates

  • Computers and phones: processors are built from billions of NAND and NOR based gates.
  • Arithmetic circuits: adders, subtractors and multipliers use XOR, AND and OR gates.
  • Memory: flip-flops and latches are made from cross-connected NAND or NOR gates.
  • Security systems: alarms, keypads and door locks combine sensor inputs using AND and OR logic.
  • Industrial control: safety interlocks use AND logic so a machine starts only when all conditions are met.
  • Digital displays: decoders turn binary numbers into seven-segment digits.
  • Communication: error checking uses XOR based parity circuits.

Practical Tips for Using Logic Gates on a Breadboard

  • Always connect the chip’s power pins (VCC and GND) before testing.
  • Never leave inputs floating. Unused inputs should be tied to VCC or ground (or to a used input), or the output may behave randomly.
  • Use a pull-down resistor (about 10 kΩ) on switch inputs so they read a clean LOW when open.
  • Add a 0.1 µF capacitor near the chip’s power pins to reduce noise.
  • Do not mix 5 V TTL outputs with 3.3 V CMOS inputs without checking voltage limits.
  • Check the datasheet for pin numbers, since each chip has its own layout.

Propagation Delay

Real gates are not instant. The time between an input change and the output change is called propagation delay. It is typically a few nanoseconds to tens of nanoseconds, depending on the logic family. In large circuits, delays add up and set the maximum clock speed.

Frequently Asked Questions About Logic Gates

What are logic gates?
Logic gates are electronic circuits that make decisions using binary inputs (0 and 1). Each gate follows a fixed rule, such as AND, OR or NOT, to produce one output.

What are the basic logic gates?
The three basic gates are AND, OR and NOT. NAND, NOR, XOR and XNOR are derived from them.

What is an AND gate in simple words?
An AND gate gives a HIGH output only when all of its inputs are HIGH. If even one input is LOW, the output is LOW.

What is an OR gate in simple words?
An OR gate gives a HIGH output when at least one input is HIGH. The output is LOW only when all inputs are LOW.

What does a NOT gate do?
A NOT gate, or inverter, flips its input. A HIGH input gives a LOW output, and a LOW input gives a HIGH output.

What is a NAND gate and how does it work?
A NAND gate is an AND gate followed by a NOT gate. Its output is LOW only when all inputs are HIGH, and HIGH in every other case.

Why is the NAND gate called a universal gate?
You can build every other gate (NOT, AND, OR, NOR, XOR) and any digital circuit using only NAND gates. This makes manufacturing simpler and cheaper.

What is the difference between an AND gate and a NAND gate?
Their outputs are always opposite. AND outputs 1 only for inputs 1 and 1. NAND outputs 0 only for inputs 1 and 1.

What is a truth table?
A truth table lists every possible combination of inputs and the output the gate gives for each one. A gate with n inputs has 2^n rows.

What is the difference between a logic gate and a flip-flop?
A logic gate has no memory, so its output depends only on its current inputs. A flip-flop remembers a bit, because its output also depends on its previous state. Flip-flops are built from gates.

Which IC should I buy to build an AND, OR, NOT or NAND gate?
Common choices are 74HC08 (AND), 74HC32 (OR), 74HC04 (NOT) and 74HC00 (NAND). Each 74HC chip works at a wide range of supply voltages (about 2 V to 6 V), which makes it good for beginners.

What happens if I leave a gate input unconnected?
The input is “floating” and can pick up noise. The output may switch randomly or the chip may draw extra current. Always tie unused inputs to a defined HIGH or LOW level.

Are logic gates used in microcontrollers and computers?
Yes. Every digital device, including microcontrollers, CPUs and memory chips, is made from logic gates at its core.

Conclusion

AND, OR, NOT and NAND gates are the foundation of digital electronics. AND needs all inputs HIGH, OR needs at least one HIGH, NOT flips the signal, and NAND is the inverse of AND. Because NAND can build every other gate, it is the most important gate in chip design. Once you understand truth tables and Boolean expressions, you can design circuits from simple alarms to full processors.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top