Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Electronics Basics

Logic Gates Basics: AND, OR, NOT, NAND, NOR Explained

Logic Gates Basics: AND, OR, NOT, NAND, NOR Explained

March 11, 2026 /Posted byJayesh Jain / 0

Logic gates are the fundamental building blocks of every digital system you use — from the smartphone in your pocket to the microcontroller on your Arduino board. Understanding logic gates basics is the first step to mastering digital electronics, and once you see how these simple circuits work, everything from CPUs to FPGAs starts to make sense.

In this comprehensive guide, we will break down every major type of logic gate — AND, OR, NOT, NAND, NOR, XOR, and XNOR — explain their truth tables, show you their circuit symbols, and help you see exactly how they are used in real projects.

Table of Contents

  1. What Are Logic Gates?
  2. AND Gate
  3. OR Gate
  4. NOT Gate (Inverter)
  5. NAND Gate
  6. NOR Gate
  7. XOR Gate
  8. XNOR Gate
  9. Universal Gates: NAND and NOR
  10. Real-World Applications
  11. Logic Gates with Arduino
  12. Frequently Asked Questions

What Are Logic Gates?

A logic gate is an electronic circuit that performs a Boolean operation — it takes one or more binary inputs (0 or 1, LOW or HIGH, false or true) and produces a single binary output. The behaviour of each gate is described by its truth table, which lists every possible combination of inputs alongside the corresponding output.

Logic gates are implemented in hardware using transistors. Modern integrated circuits pack billions of transistors onto a single chip, and each group of transistors forms one or more logic gates. When you write code for an Arduino or Raspberry Pi, the processor underneath is executing your instructions by toggling millions of these gates every second.

The mathematical framework behind logic gates is Boolean algebra, developed by George Boole in the 19th century and later applied to electrical circuits by Claude Shannon in the 1930s. Shannon proved that any logical relationship could be expressed using combinations of AND, OR, and NOT operations — which is exactly why these three form the foundation of all digital logic.

Binary Logic Levels

In TTL (Transistor-Transistor Logic) circuits operating at 5V:

  • Logic HIGH (1): Typically 2.4V to 5V
  • Logic LOW (0): Typically 0V to 0.8V

In 3.3V CMOS systems (like most modern microcontrollers), the thresholds shift accordingly. Understanding these voltage levels is crucial when interfacing different logic families.

0 Ohm 0.25W Carbon Film Resistor

0 Ohm 0.25W Carbon Film Resistor (Pack of 100)

Ideal for building pull-up/pull-down networks on logic gate breadboard circuits and prototype boards.

View on Zbotic

AND Gate

The AND gate is one of the most intuitive logic gates. Its output is HIGH only when all inputs are HIGH. Think of it as a series switch circuit — both switches must be closed for current to flow.

AND Gate Truth Table (2-Input)

Input A Input B Output (A AND B)
0 0 0
0 1 0
1 0 0
1 1 1

Boolean expression: Y = A · B (or A AND B)

Real-life analogy: A car that starts only when the key is turned AND the seatbelt is buckled.

IC example: 74LS08 (quad 2-input AND gate)

OR Gate

The OR gate outputs HIGH when at least one input is HIGH. It corresponds to a parallel switch circuit — either switch being closed allows current to flow.

OR Gate Truth Table (2-Input)

Input A Input B Output (A OR B)
0 0 0
0 1 1
1 0 1
1 1 1

Boolean expression: Y = A + B (or A OR B)

Real-life analogy: A room light that turns on when either person A or person B flips a switch.

IC example: 74LS32 (quad 2-input OR gate)

NOT Gate (Inverter)

The NOT gate is the simplest logic gate — it has only one input and one output, and it simply inverts the input. A HIGH becomes LOW, and a LOW becomes HIGH. The NOT gate is also called an inverter.

NOT Gate Truth Table

Input A Output (NOT A)
0 1
1 0

Boolean expression: Y = A’ (or Ā or NOT A)

Real-life analogy: An active-low LED driver — the LED is ON when the input is LOW.

IC example: 74LS04 (hex inverter)

2N2222 NPN Transistor

2N2222 NPN Transistor (Pack of 20)

At its core, a NOT gate is just a transistor inverter. Build your own inverter circuit with these 2N2222 NPN transistors.

View on Zbotic

NAND Gate

NAND stands for NOT AND. The output of a NAND gate is the inverse of an AND gate — the output is LOW only when all inputs are HIGH, and HIGH in all other cases.

NAND Gate Truth Table (2-Input)

Input A Input B Output (A NAND B)
0 0 1
0 1 1
1 0 1
1 1 0

Boolean expression: Y = (A · B)’

Why NAND matters: The NAND gate is one of the two universal gates. You can build every other logic gate using only NAND gates. This makes NAND-based designs extremely common in real ICs.

IC example: 74LS00 (quad 2-input NAND gate) — one of the most widely used ICs ever manufactured.

NOR Gate

NOR stands for NOT OR. Its output is HIGH only when all inputs are LOW — the inverse of the OR gate.

NOR Gate Truth Table (2-Input)

Input A Input B Output (A NOR B)
0 0 1
0 1 0
1 0 0
1 1 0

Boolean expression: Y = (A + B)’

IC example: 74LS02 (quad 2-input NOR gate)

Like NAND, the NOR gate is also a universal gate. The first integrated circuits were entirely NOR-gate based — the Apollo Guidance Computer used NOR gates exclusively.

XOR Gate

XOR stands for Exclusive OR. The output is HIGH when the inputs are different. If both inputs are the same (both 0 or both 1), the output is LOW.

XOR Gate Truth Table (2-Input)

Input A Input B Output (A XOR B)
0 0 0
0 1 1
1 0 1
1 1 0

Boolean expression: Y = A ⊕ B

Key application: XOR gates are the heart of binary adders (half adders use one XOR gate). They are also used in parity checking, error detection, and encryption (XOR cipher).

IC example: 74LS86 (quad 2-input XOR gate)

XNOR Gate

XNOR (Exclusive NOR) is the complement of XOR. The output is HIGH when both inputs are the same.

XNOR Gate Truth Table (2-Input)

Input A Input B Output (A XNOR B)
0 0 1
0 1 0
1 0 0
1 1 1

Boolean expression: Y = (A ⊕ B)’

Key application: Equality detectors, digital comparators, parity generators.

Universal Gates: NAND and NOR

A universal gate is one that can implement any Boolean function without needing any other type of gate. Both NAND and NOR are universal gates, which is why chip manufacturers often use just one gate type throughout an entire design to simplify fabrication.

Building All Gates from NAND

  • NOT from NAND: Connect both inputs together (A NAND A = NOT A)
  • AND from NAND: NAND followed by NOT (invert the NAND output)
  • OR from NAND: Invert both inputs, then NAND them (De Morgan’s theorem)
  • NOR from NAND: Build OR from NAND, then NOT it
  • XOR from NAND: Requires 4 NAND gates
Female to Female Jumper Wires

10CM Female To Female Breadboard Jumper Wires – 40Pcs

Connect logic gate ICs to your breadboard and Arduino effortlessly with these quality jumper wires.

View on Zbotic

Real-World Applications of Logic Gates

Logic gates are not just textbook theory — they are in every digital device you own. Here is where you encounter them in real life:

1. Arithmetic Logic Units (ALUs)

The ALU inside every CPU uses combinations of XOR, AND, and OR gates to perform addition, subtraction, and bitwise operations. A simple 1-bit full adder requires just XOR and AND gates.

2. Memory (Flip-Flops and Latches)

SR latches are built from NAND or NOR gates. These bistable circuits form the basis of SRAM and register files. Every variable stored in your microcontroller’s registers lives in a circuit of interconnected NAND gates.

3. Multiplexers and Decoders

Multiplexers use AND and OR gates to route data from multiple sources to a single output. Decoders use AND gates to activate one specific output from a binary-encoded input — used in memory address decoding.

4. Error Detection

XOR gates compute parity bits. A simple even parity generator XORs all data bits together to produce a check bit. If any single bit flips during transmission, the parity check fails and the error is detected.

5. Robotics and Sensor Logic

An AND gate can trigger an alarm only when sensor A AND sensor B both detect motion — reducing false positives. This kind of gate-level logic is often implemented in microcontrollers using bitwise operations.

Simulating Logic Gates with Arduino

You can simulate any logic gate in Arduino using simple conditional statements or bitwise operators. Here is how all five gates look in code:

// Logic gate simulation in Arduino
int A = digitalRead(2);  // Input A
int B = digitalRead(3);  // Input B

// AND Gate
int andResult = A & B;

// OR Gate
int orResult = A | B;

// NOT Gate
int notResult = !A;

// NAND Gate
int nandResult = !(A & B);

// NOR Gate
int norResult = !(A | B);

// XOR Gate
int xorResult = A ^ B;

// XNOR Gate
int xnorResult = !(A ^ B);

This is essentially how microcontrollers execute logical operations internally — the hardware gate arrays are abstracted away into these clean bitwise operators.

Practical Project: 2-Input Logic Gate Tester

Connect two pushbuttons to pins 2 and 3 (with pull-down resistors) and an LED to pin 13. Upload the AND gate code and press different button combinations — the LED lights up only when both buttons are pressed simultaneously. Swap in other gate logic and observe the different behaviours. This simple project builds deep intuition for how gates work.

Metal Film Resistor

1.5 Ohm 1/4W Metal Film Resistor (Pack of 100)

Precision resistors for building pull-down networks and current limiting in your logic gate experiments.

View on Zbotic

Frequently Asked Questions

What is the difference between NAND and NOR gates?

NAND is the inverse of AND — output is LOW only when all inputs are HIGH. NOR is the inverse of OR — output is HIGH only when all inputs are LOW. Both are universal gates, meaning you can build any other gate type using only NANDs or only NORs.

Why are NAND gates called universal gates?

NAND gates are called universal because every other logic function (NOT, AND, OR, NOR, XOR, XNOR) can be implemented using only NAND gates. This simplifies chip manufacturing since only one type of gate cell needs to be optimised and laid out. The same applies to NOR gates.

How many transistors does a basic logic gate use?

In CMOS technology: a NOT gate uses 2 transistors (1 PMOS + 1 NMOS), a NAND gate uses 4, an AND gate uses 6, an OR gate uses 6, and a NOR gate uses 4. NAND and NOR are simpler to implement than AND and OR in CMOS, which is another reason they are preferred.

What is the use of XOR gate in electronics?

XOR gates are primarily used in binary arithmetic (half adders and full adders), parity generators and checkers for error detection, encryption and decryption circuits (XOR cipher), comparators, and pseudo-random number generators (LFSRs). They are one of the most versatile logic gates in digital design.

Can I build logic gates on a breadboard?

Yes! The easiest way is to use 74-series logic gate ICs like the 74LS00 (NAND), 74LS02 (NOR), or 74LS08 (AND). These DIP-package ICs plug directly into a breadboard. You can also build individual gates from discrete transistors and resistors for a deeper understanding of how gates work at the transistor level.

Start Building with Logic Gates Today

Now that you understand logic gates basics, it is time to get hands-on. Zbotic stocks everything you need — from jumper wires and resistors to transistors and prototype PCBs — to bring your digital logic experiments to life.

Shop Electronics Components at Zbotic

Tags: Arduino, boolean algebra, digital electronics, electronics basics, logic gates
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Gear Reduction Motor: How to C...
blog gear reduction motor how to calculate output speed torque 596679
blog pcb trace width calculator current capacity and heat management 596682
PCB Trace Width Calculator: Cu...

Related posts

Svg%3E
Read more

Coffee Roaster: Temperature Profile Controller Build

April 1, 2026 0
Table of Contents Why Build a Coffee Roaster? Roasting Temperature Profiles Components for the Build Thermocouple Placement PID Profile Controller... Continue reading
Svg%3E
Read more

Sous Vide Cooker: Precision Temperature Water Bath

April 1, 2026 0
Table of Contents What Is Sous Vide Cooking? Precision Temperature Requirements Components for the Build PID Temperature Controller Water Circulation... Continue reading
Svg%3E
Read more

Kiln Controller: High-Temperature Pottery Automation

April 1, 2026 0
Table of Contents What Is a Kiln Controller? Temperature Requirements for Ceramics Components for High-Temperature Control K-Type Thermocouple and MAX6675... Continue reading
Svg%3E
Read more

Heat Gun Controller: Temperature and Airflow Regulation

April 1, 2026 0
Table of Contents What Is a Heat Gun Controller? Temperature and Airflow Regulation Components for the Build PID Temperature Control... Continue reading
Svg%3E
Read more

Soldering Iron Station: PID Temperature Controller Build

April 1, 2026 0
Table of Contents Why Build a Soldering Station? PID Temperature Control for Soldering Components Required Thermocouple Sensing at the Tip... Continue reading

Add comment Cancel reply

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

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now