Learn

A truth table is easier to believe when you can press it

Sign up freeor see every lesson
  • 192parts on the bench
  • 25boards running now
  • 1.00xreal time, on every board
Gate lablive0.000 s 0.00x
Hold the button
Two buttons drive an AND, an XOR and a NOT gate. Hold either one and read the three LEDs.

An AND gate outputs 1 only when both inputs are 1. An XOR outputs 1 only when its inputs differ. A NOT simply inverts whatever it is given. Every logic textbook has this table; the circuit above has it as three LEDs you can watch change under your own thumb, with two buttons standing in for the two inputs.

Both buttons need a pull-down resistor to work as a clean digital input, and this is the same reasoning as the page on pull-up resistors, mirrored: a 10 kilohm resistor between each button's net and ground holds that input at a real 0 V while the button is not pressed, since a floating CMOS input is not a zero, it is whatever charge was last on it. Pressing a button connects its net to 5 V, which easily overpowers the weak pull-down and reads as a clean 1.

The three gates here are the ideal kind: no supply pins to wire, a few nanoseconds of propagation delay, and a push-pull 5 V output that drives its LED directly. That delay is not just a number sitting unused, either. It is inertial: a change on an input that gets reversed before the delay has elapsed never reaches the output at all, which is the same thing a real gate's finite switching speed does to a pulse too narrow to matter. Ten nanoseconds is short enough that nothing on this page notices it by eye, but it is there in the model, and it is why a gate built from real 74HC chips (see the logic gate simulator page) behaves the same way at a slower, measurable nine nanoseconds instead.

Worth trying on the running circuit: hold both buttons at once and watch the AND LED come on while the XOR LED goes out, which is the one row of the table where they disagree. Then let go of one and watch them swap. The NOT gate only ever looks at input A, so it answers regardless of what button B is doing, which is a good way to notice that a gate answers about its own inputs and nothing else on the board.

The real chips waiting one step further along are the 74HC00 (NAND), 74HC04 (inverter), 74HC08 (AND), 74HC32 (OR) and 74HC86 (XOR), each a 14-pin DIP with its own VCC and GND pins that have to be wired for the chip to do anything at all. An unpowered real chip's outputs sit high-impedance, not at 0, which is the single most common reason a beginner's logic circuit built from real chips does nothing at first glance.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.