## Introduction

We all know that computers are made using thousands (or millions) of transistors, but not many of us have "hands on" experience of constructing the fundamental building-blocks of digital logic ourselves. Those building blocks are "logic gates".

I decided to experiment with making my own logic gates using some of the many Snap Circuits components I have accumulated over the years.

In electronics, a logic gate is a device implementing a Boolean function. Every possible logical function can be represented by a combination of only NAND gates or only NOR gates. In practice, other common logic gates such as AND, OR, NOT and XOR are also used as building blocks.

## Transistors

Turning now to the transistor, if a sufficient voltage is applied between the collector and base (normally ~ 0.7V), this will allow current to flow between the collector and the emitter (i.e. it will "turn on" the transistor).

A judicious choice of base resistor is necessary to prevent excessive current flowing through the base (destroying the transistor). Also, a "load" resistor should be chosen that allows sufficient but not excessive current to flow through the load device (i.e. output device). For my circuit, I used a 4.5V battery pack and NPN transistors (with base resistors of 1k Ohms) driving an LED through a 100 Ohm load (plus the 33 Ohm internal resistor). By applying sufficient (analogue) base voltage until current flows from the collector through the emitter, we have made a digital device (an electronic switch). This is the starting point for digital electronics.

## Logic gates

The first, and simplest logic gate I built was the NOT gate (also known as an inverter). This needs just one transistor. If the input voltage is "high" (in logic terms "1"), then the output voltage is "low" (in logic terms "0") and vice versa.

Next I built a NAND gate. This needs two transistors in series, with the output load being driven between the collector and ground (0V). nb. You can turn it into an AND gate by placing the load between the supply voltage and the collector.

The function of a NAND gate can be expressed in the truth table below (see All About Circuits):

The final "building block" logic gate I built was a NOR gate which needs two transistors in parallel.

The truth table is as follows:

Now for something a bit more complicated - an Exclusive-OR ("XOR") gate. This outputs a “high” ("1") logic level if the inputs are at different logic levels, either 0 and 1 or 1 and 0. Conversely, it outputs a “low” ("0") logic level if the inputs are at the same logic levels.

XOR gates can be constructed from various combinations of AND, OR, NAND, NOR or NOT gates. I made mine from pairs of NAND and NOT gates.