Computer NAND Gate

The NAND gate is a foundational building block in computational redstone because it can be combined to create any other logic gate. In this tutorial, you will learn how to construct a basic NAND gate, wire four of them together into an XOR (Exclusive OR) gate, and expand that setup with a carry-out line to add binary numbers.

Logic GatesIntermediateJava Edition
Computer NAND Gate video tutorial

Video: Redstone Computer Tutorial - Episode 2 - The Mighty NAND Gate by Redstone Without Limits

How to build it

  1. Build the First NAND Gate

    Place a row of 3 solid blocks with a Redstone Torch on top of the two outer blocks, and a patch of Redstone Dust on top of the center block. Unlike a standard AND gate, leave the output line un-inverted so that the gate outputs a signal by default until both inputs are turned on.

  2. Attach the Input Levers

    Place two levers on your input lines (labeled Input A and Input B) leading into the two outer torch blocks of your first NAND gate.

  3. Add Two Intermediate NAND Gates

    Build two more NAND gates slightly ahead and to the left and right of your first gate. Split the output dust line from the center of your first NAND gate and route it into one input of each of these two new NAND gates.

  4. Branch the Main Inputs

    Run a secondary redstone line from Input A directly into the remaining free input of the left intermediate NAND gate. Do the same for Input B, routing a branch into the free input of the right intermediate NAND gate.

  5. Connect the Fourth NAND Gate (XOR Output)

    Build a fourth NAND gate ahead of the middle two. Route the outputs from both intermediate NAND gates into the two inputs of this fourth gate to complete a 4-NAND XOR circuit.

  6. Place the First Bit Indicator

    Attach a Piston with a wool block on top (or a Redstone Lamp) to the output of the fourth NAND gate. This acts as your 1s place bit (Sum) and will only activate when exactly one of the two input levers is switched on.

  7. Wire the Carry-Out Bit

    To turn the XOR gate into a binary half-adder, tap into the output of the very first NAND gate before the intermediate gates. Route this line over to the side using a block bridge to cross over existing wires without connecting them, and invert or connect it to a second indicator representing the 2s place (Carry Out).

How it works

This circuit demonstrates universal NAND logic and binary place values (1, 2, 4, 8):

  • Single NAND Gate: A NAND (Not-AND) gate consists of two inverted inputs merged with redstone dust. As long as at least one input is OFF, its corresponding torch stays lit and powers the output line. Only when both inputs are ON do both torches turn off, cutting power to the output.
  • 4-NAND XOR Gate: By chaining four NAND gates together, you create an Exclusive OR gate. When one lever is flipped ON, the first NAND gate stays active, allowing the opposite intermediate gate to toggle and turn the final fourth NAND gate's output ON.
  • Binary Addition & Carry Out: In base-2 (binary), each line represents a single bit that can only hold a 0 or a 1. Flipping one lever outputs a 1 in the 1s place. Flipping both levers (1 + 1) exceeds the capacity of the first bit; the XOR gate turns the 1s place back to 0, while the line tapped from the first NAND gate shifts a signal over to the 2s place (Carry Out), representing the number 2 in binary (10).

Tips & variations

  • Crossing Wires: When routing the Carry Out line from the first NAND gate over to the second bit, use solid blocks to step the redstone dust up and over perpendicular lines so the signals do not merge.
  • Signal Strength: Because a 4-NAND XOR gate routes signals through multiple stages, keep an eye on the 15-block redstone dust power limit and add a Redstone Repeater if your lines get too long.
  • Compact Alternatives: Building an XOR gate out of four individual NAND gates is great for learning computer architecture, though in survival builds you can also make smaller XOR gates using comparators or piston logic.

Frequently asked questions

How is a NAND gate different from an AND gate?
An AND gate has a third redstone torch on the output to invert the signal so it only turns on when both inputs are on. A NAND gate omits that final inverting torch, meaning its output stays on unless both inputs are activated simultaneously.
Why build an XOR gate out of four NAND gates?
In computer science and redstone computing, the NAND gate is a 'universal gate,' meaning every other logic gate (AND, OR, XOR, NOT) can be constructed entirely out of combinations of NAND gates.
What is the Carry Out (C-Out) line used for?
In binary addition, a single bit can only display up to 1. When you add 1 + 1, the first bit resets to 0 and the Carry Out line sends a signal to the next bit (the 2s place) to represent the value 2.

Components used

More nand gate