Logic Gates Explained — A logic gate turns voltage levels into a decision. Learn the seven basic gates, how to read a truth table and what to check before mixing logic.

Digital

Logic Gates Explained

Logic Gates Explained — A logic gate turns voltage levels into a decision. Learn the seven basic gates, how to read a truth table and what to check before mixing logic.

A logic gate turns voltage levels into a decision. Learn the seven basic gates, how to read a truth table and what to check before mixing logic families.

22 November 20267 min read

Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →

Get the parts

If you want to build a real circuit, you can get the parts from hobidevre.com → hobidevre.com →

More build guides: hobidevre.com/blog

What a logic gate is

A logic gate accepts one or more inputs and produces an output that represents a Boolean decision. In hardware, the two states are ranges of voltage rather than exact numbers: a level near the supply means one state and a level near ground means the other.

The relationship between inputs and output is described by a truth table, which lists every input combination and the resulting output. Once you can read a truth table, you can reason about a gate without needing to know what happens inside the silicon.

The three building blocks

An AND gate outputs the one state only when all inputs are in that state; its expression is A times B. An OR gate outputs the one state when at least one input is in that state; its expression is A plus B. A NOT gate, or inverter, has one input and flips it.

For two inputs, AND gives a single high row in its truth table, OR gives three, and NOT turns each input state into the opposite output. These three functions can be combined to build any digital operation.

The derived gates

A NAND gate is an AND followed by an inverter: its output is low only when all inputs are high. A NOR gate is an OR followed by an inverter: its output is high only when all inputs are low. Both are called universal because either one alone can build any other gate.

An XOR gate outputs the one state when its inputs differ, which makes it useful for adders and comparison. An XNOR is the inverse and outputs the one state when the inputs match. Truth tables make these distinctions obvious at a glance.

Reading a truth table

For n inputs there are two to the power of n rows. A two-input table has four rows and a three-input table has eight. Read across each row: the left columns are the inputs and the right column is the output for that exact combination.

When a circuit misbehaves, build the truth table for what you expect and compare it with what you measure. A mismatch in one row often points to a single stuck input rather than a faulty chip.

Voltage levels and families

TTL and CMOS families define different voltage ranges for a valid high or low. A level that counts as high for one family may be ambiguous for another, so check the datasheet before connecting families directly.

When supplies differ, use a level-shifting method suited to the direction and speed of the signal. Assuming that all logic uses the same thresholds is a reliable way to create an intermittent fault that appears only with certain chips.

Practical notes

  • Never leave a CMOS input floating; tie it to a defined level through a resistor or a pull-up.
  • Place a small decoupling capacitor close to each logic chip’s supply pins.
  • Respect fan-out: one output can only drive a limited number of inputs.
  • Open-collector or open-drain outputs need an external pull-up to reach a high state.

Slow edges on an input can cause a gate to switch more than once. If a signal comes from a mechanical switch, debounce it before it reaches a clock or counter input.

Common mistakes

  1. Reading a truth table with the input order reversed.
  2. Assuming an unconnected input reads low.
  3. Mixing logic families without checking voltage levels.
  4. Forgetting that an inverter with its output tied back can oscillate.

Work from the table, measure the pins, and change one thing at a time. That routine resolves most gate-level confusion quickly.

Frequently asked questions

Which gates are universal?

NAND and NOR. Either can be wired to reproduce AND, OR and NOT, which is why they appear so often in logic design.

What is the difference between XOR and OR?

OR is high when at least one input is high, including when both are high. XOR is high only when the inputs differ.

Why must CMOS inputs be tied off?

A floating input can drift to an arbitrary level and switch unpredictably, increasing power draw and causing erratic output.

Can I connect a 3.3 V gate to a 5 V input?

Only if the input is tolerant of that voltage or you use a level shifter. Check both datasheets before connecting.

Related reading

Practise in the browser

Open a circuit in the simulator and follow the checks. Sign in to save your work.