Skip main navigation

What is a NAND Gate?

In this step, you are going to have a look at how transistors can be combined together to form what are called logic gates, and in particular you will look at the NAND gate.

In this step, you are going to have a look at how transistors can be combined together to form what are called logic gates, and in particular you will look at the NAND gate.

Transistors

You may already know how transistors can be used to represent the value 1 or 0 by acting like simple switches. You are now going to look at combining these transistors together so they can perform more complex operations.

 

The diagram below shows a circuit containing two transistors. Again, you don’t have to understand what is going on in this circuit, just as long as you can understand the basic inputs and outputs.

 

A circuit where two switches each control the current going to the base of a transistor. The transistors are connected in series with each other, and in parallel with an LED.

 

The two switches act as inputs to the transistor setup, and the LED represents the output. When both switches are in the off position, the LED is on. Either of the switches can be turned on, leaving the other one off, and the LED still stays on. It’s only when both switches are turned on that the LED will switch off.

 

An animation showing the circuit from the previous image, with the LED remaining on apart from when both switches are switched to "on".

 

This arrangement of transistors is called a NAND gate, and you’ll learn about why later.

 

NAND Gate Symbol

Now, rather than drawing two transistors every time you want to represent a NAND gate, you can use a symbol that looks like this.

 

A symbol that looks like an extended D with a small circle touching its right-most point. Two inputs and an output are represented with larger circles connected with straight lines - the inputs are connected on the left-hand side approximately one quarter and three quarters of the way down the straight edge of the D, and the output is connected on the right-hand side to the small circle.

 

Whether you use this symbol or show the two transistors, the behaviour of the NAND gate is the same. When both switches are off, the output is on. Turning either of the switches individually doesn’t affect the output. Only when both switches are in the “on” position does the output become “off”.

 

An animation showing two switches connected to the inputs of a NAND gate symbol, with the output connected to a bulb. The bulb remains on apart from when both switches are switched on, at which point the bulb is off.

 

NAND Gate Truth Table

You can represent this behaviour by drawing what is called a truth table, where the states of the switches are represented by 1s and 0s. When both switches are off, the inputs are both 0. Since the lamp is on, the output in this state is 1. If you turn one of the switches to the “on” position, the corresponding input is 1; the lamp remains on, so the output is 1. Only when both inputs are 1 does the output change to 0.

 

An animation showing the truth table for the NAND gate being constructed. The switches, gate, and bulb from the previous animation are on the left. On the right is a table with 3 columns, labelled "Input A", "Input B", and "Output". As the states of the switches and hence the bulb are changed, this table updates with values.

 

So the full truth table for a NAND gate is as shown below.

 

A table with three columns, labelled "Input A", "Input B", and "Output". The first row reads 0 0 1, the second 1 0 1. The third row reads 0 1 1 and the final row 1 1 0.

 

You can play with your own simulation of a NAND gate on the website CircuitVerse.

 

A screenshot of circuitverse.org, showing a NAND gate attached to two digital inputs and a digital LED. The inputs are both at 1 and the LED is off

 

Here, you can select different gates, and choose inputs, which can be 1 or 0, with outputs in the form of a digital LED. This will allow you to play around with a NAND gate and investigate the truth table for yourself.

You could even have a go at experimenting with different types of gate.

This article is from the free online

How Computers Work: Demystifying Computation

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education