How to Make a NAND Gate With Transistors

A NAND gate is one of the simplest logic circuits you can build, and you can do it with just two NPN transistors, a couple of resistors, and a 5V power source. It outputs HIGH (1) in every case except when both inputs are HIGH, at which point the output drops to LOW (0). Below is everything you need to build one from scratch, plus how to use a ready-made IC chip if you want something quicker.

How a NAND Gate Works

A NAND gate performs an AND operation and then inverts the result. If you feed two inputs (A and B) into it, the only combination that produces a LOW output is when both A and B are HIGH. Every other combination gives you a HIGH output:

  • A = 0, B = 0 → Output = 1
  • A = 0, B = 1 → Output = 1
  • A = 1, B = 0 → Output = 1
  • A = 1, B = 1 → Output = 0

In a standard 5V circuit, “HIGH” means a voltage above roughly 2V (for TTL-style logic) or 3.5V (for CMOS logic), and “LOW” means a voltage near 0V. These thresholds matter when you’re building with transistors, because your circuit needs to swing clearly between those ranges to register as a proper digital signal.

Building a NAND Gate With Transistors

The classic way to build a NAND gate is with two NPN transistors wired in series. The 2N2222 is the go-to transistor for this kind of project because it’s cheap, widely available, and handles 5V logic easily.

Parts You Need

  • Two 2N2222 NPN transistors
  • Two 10kΩ resistors (for the base of each transistor)
  • One 4.7kΩ resistor (pull-up resistor connecting VCC to the output)
  • A 5V power supply (a USB breakout board or 4×AA batteries works fine)
  • A breadboard and jumper wires
  • An LED and a 330Ω resistor (optional, to visually confirm the output)

Circuit Layout

The key idea: the two transistors sit in series between the output node and ground. The output is tapped from above them, pulled up to 5V through the 4.7kΩ resistor. Only when both transistors are turned on (both inputs HIGH) does current flow through to ground, pulling the output LOW. In every other case, the output stays HIGH because it’s connected to 5V through that pull-up resistor.

Here’s how to wire it step by step:

Connect the collector of transistor Q1 to the 4.7kΩ pull-up resistor, and connect the other end of that resistor to your 5V supply rail. This junction between Q1’s collector and the resistor is your output. Connect Q1’s emitter to Q2’s collector. Then connect Q2’s emitter to ground.

For the inputs, connect a 10kΩ resistor from input A to the base of Q1, and another 10kΩ resistor from input B to the base of Q2. The 10kΩ resistors limit the current flowing into each transistor’s base to about 0.26mA, which is enough to switch the transistor on without damaging it. The 4.7kΩ pull-up resistor limits current to roughly 1.3mA, keeping power consumption low while still providing a solid HIGH signal at the output.

To test it, connect your inputs to either 5V (for logic HIGH) or ground (for logic LOW) using jumper wires. If you wire an LED with a 330Ω resistor from the output to ground, it will light up whenever the output is HIGH and go dark only when both inputs are HIGH.

Using a 74HC00 NAND Gate IC

If you don’t want to build from individual transistors, the 74HC00 is a standard chip that contains four independent 2-input NAND gates in a single 14-pin package. It’s one of the most common ICs in digital electronics and costs well under a dollar.

The pinout is straightforward. Pin 14 connects to your power supply (VCC), and pin 7 connects to ground. The chip accepts supply voltages from 2V to 6V, so a standard 5V source works perfectly. Each of the four gates has two input pins and one output pin:

  • Gate 1: inputs on pins 1 and 2, output on pin 3
  • Gate 2: inputs on pins 4 and 5, output on pin 6
  • Gate 3: inputs on pins 9 and 10, output on pin 8
  • Gate 4: inputs on pins 12 and 13, output on pin 11

Drop the chip into a breadboard, wire up power and ground, and you have four NAND gates ready to use. No resistors or external components needed. It’s a good idea to place a small capacitor (0.1µF) between VCC and GND close to the chip to filter out noise on the power line, but the circuit will work without it for simple experiments.

Why NAND Gates Matter: The Universal Gate

NAND is called a “universal gate” because you can build every other type of logic gate using nothing but NAND gates. This is why it’s the foundational building block of most digital circuits, including processors and memory chips.

A NOT gate is the simplest. Connect both inputs of a NAND gate to the same signal. When the input is HIGH, both inputs are HIGH, so the output goes LOW. When the input is LOW, the output goes HIGH. That’s an inverter.

An AND gate takes two NAND gates. Run your two inputs through the first NAND gate, then feed that output into a second NAND gate wired as a NOT (both inputs tied together). The first NAND gives you the inverted AND result, and the second NAND flips it back, giving you a standard AND output.

An OR gate also takes three NAND gates. Invert each input separately using two NAND gates wired as NOT gates, then feed those inverted signals into a third NAND gate. This works because of a rule in Boolean algebra called De Morgan’s theorem: inverting both inputs before a NAND operation is equivalent to an OR operation.

This universality is why a single 74HC00 chip with four NAND gates can be surprisingly versatile. With enough of them, you can construct any digital circuit that exists.

Troubleshooting Common Problems

If your transistor-based circuit isn’t behaving correctly, the most common issue is floating inputs. An input that isn’t connected to anything doesn’t reliably read as LOW. It picks up stray electrical noise and can fluctuate unpredictably. Always tie unused inputs to either 5V or ground with a wire.

If your output voltage seems stuck in a middle range (say, around 1.5V to 2.5V) instead of swinging cleanly between near-0V and near-5V, check that your transistors are fully saturating. This usually means the base resistor value is too high, not allowing enough current to fully switch the transistor on. Try dropping from 10kΩ to 4.7kΩ on the base resistors and see if the output cleans up.

For the 74HC00 IC, the most frequent mistake is forgetting to connect pin 7 to ground or pin 14 to VCC. Without both power connections, the chip won’t function at all. Also verify that you’re counting pins correctly: pin 1 is marked with a dot or notch on the chip, and numbering goes counterclockwise when viewed from above.