ABC of Electronics cosycom.com
LESSON 21

Digital Logic Gates

The AND, OR, NOT and XOR gates that every digital circuit — from a doorbell to a CPU — is built from.

Everything you've studied so far has been analog — voltages that can sit anywhere between 0V and your supply rail. Digital electronics throws that away on purpose. A digital signal only ever means one of two things: HIGH (roughly your supply voltage, read as a logical "1") or LOW (roughly 0V, read as a logical "0"). That simplification is what makes reliable computers possible — a bit of electrical noise that would confuse an analog signal barely matters when the circuit only cares whether a voltage is "high enough" or "low enough."

A logic gate is a small circuit, usually built from a handful of transistors, that takes one or more digital inputs and produces a digital output based on a fixed rule. The four you'll meet constantly:

  • NOT — flips its single input. Feed it a 1, get a 0, and vice versa.
  • AND — output is 1 only if every input is 1.
  • OR — output is 1 if at least one input is 1.
  • XOR (exclusive OR) — output is 1 if the inputs are different from each other.

You can chain gates together the same way you chain resistors — the output of one becomes the input of the next. A handful of gates wired together can add two numbers; a few billion of them, wired together, is a modern CPU. Gates are usually sold as small ICs (like the 74HC-series chips) containing several gates in one package, or built directly into a microcontroller.

A quick way to reason about any gate is a truth table — a list of every possible input combination and the resulting output. For a 2-input AND gate: 0+0→0, 0+1→0, 1+0→0, 1+1→1. Once you can read a truth table, you can predict the behavior of any digital circuit before you power it on.

AND gate symbol Two inputs enter the flat side; the D-shaped body means "output goes high only if both inputs are high."
KEY TAKEAWAY
Digital circuits only care about HIGH and LOW. Logic gates — AND, OR, NOT, XOR — are the tiny rule-following building blocks that every microcontroller and computer is assembled from.