Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

OR gate using NAND gates: three gates, live

An OR gate takes three NAND gates: two NANDs with their inputs tied together invert A and B, and a third NANDs the inverted inputs, so Y = NAND(NOT A, NOT B) = A OR B. Try all four input rows on the live circuit below.

The reason is De Morgan's law: NOT (NOT A AND NOT B) = A OR B. A NAND gate computes exactly the left side when it is fed the inverted inputs, and a NAND with both inputs joined is an inverter (NAND(A, A) = NOT A). So OR from NAND gates is "invert both inputs, then NAND". In a schematic the same idea shows up as a NAND gate drawn with bubbles on its inputs, which is an OR. With NAND gates OR costs three gates while XOR costs four; the universal gates page builds NOT, AND, OR and NOR from NANDs side by side, and the AND gate from three NOR gates is the mirror image of this circuit.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “OR gate from NAND gates”, https://digiwleea.wleeaf.dev/tools/build/or-from-nand/

What you need

Step by step

  1. Place inputs A and B and a probe Y.
  2. Feed A into both inputs of a NAND gate: its output is NOT A. Do the same for B.
  3. NAND the two inverted signals together and probe the result as Y.
  4. Try all four rows: Y is 0 only when A and B are both 0, which is OR.

OR from NAND truth table

ABNOT ANOT BY = A OR B
00110
01101
10011
11001

The last NAND outputs 0 only when both of its inputs are 1, that is when A and B are both 0. All four rows are checked on the live circuit before the page is built.

You can also read the full theory in the lesson on the NAND gate. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.

More builds: Universal gates: NAND only, NOR only

All 246 build guides, by topic

Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.

Open the OR gate from NAND gates in the lab →

Frequently asked

How many NAND gates are needed to make an OR gate?

Three: two NAND gates used as inverters (inputs tied together) and one NAND that combines the inverted inputs. NAND(NOT A, NOT B) = A OR B by De Morgan's law.

How do you make a NOT gate from a NAND gate?

Connect both inputs of the NAND gate together. NAND(A, A) = NOT (A AND A) = NOT A.

How do you make an AND gate from NAND gates?

Use two: a NAND followed by a NAND wired as an inverter. NOT (NAND(A, B)) = A AND B.

How many NAND gates make a NOR gate?

Four: the three-NAND OR gate followed by one more NAND wired as an inverter.