Skip to content
Medium

Logic Gates and Truth Tables

Simple Explanation

Logic gates are the basic building blocks of digital circuits, each combining binary inputs according to a fixed rule: AND outputs 1 only if both inputs are 1; OR outputs 1 if at least one input is 1; NOT flips a single input. A truth table lists every possible input combination and the resulting output.

Why Do We Need It?

Every digital circuit, no matter how complex β€” including every computer processor β€” is ultimately built from combinations of these same few simple logic gates.

Formula

Basic Logic Gate Equations

AND: Y = A AND B; OR: Y = A OR B; NOT: Y = NOT A

Logic gates are the basic building blocks of digital circuits, each following a fixed rule for combining binary (0 or 1) inputs into a binary output.

A, B
β€” binary inputs (0 or 1)
Y
β€” the binary output (0 or 1)

When to use it: Whenever the output of a basic logic gate needs to be found for given binary inputs.

Worked Example

Build the truth table for an AND gate

Construct the complete truth table for a two-input AND gate.

    Why Does This Work?

    Each gate is built from an electronic circuit (like transistor switches) that physically implements its rule β€” an AND gate, for instance, only lets current reach the output when both input switches are closed (representing 1), which is exactly why the output is 1 only when every input is 1.

    Real-Life Example

    A car that only starts with the seatbelt fastened AND the brake pressed

    Some cars require both the driver's seatbelt to be fastened AND the brake pedal to be pressed before the engine will start.

    This safety interlock is exactly an AND gate: the 'start engine' output only activates when BOTH input conditions (seatbelt=1, brake=1) are true at the same time.

    Practice

    For an OR gate with inputs A=0 and B=1, find the output Y.

    Medium

    Common mistake

    Confusing AND and OR β€” AND requires EVERY input to be 1 for the output to be 1, while OR only requires AT LEAST ONE input to be 1; mixing these up gives the exact opposite truth table.

    Quick Review

    • AND: output 1 only if all inputs are 1.
    • OR: output 1 if at least one input is 1.
    • NOT: flips a single input (0 becomes 1, 1 becomes 0).