You are on page 1of 16

Digital Electronics Laboratory

Working with Logic Circuits


Implementing logic gates with transistors

Creating Logic Gates with Transistors


In a nutshell, a voltage applied to the base of a transistor allows current to flow from the
collector to the emitter. Thus, by applying an input signal to a transistor’s base, you can
control an output signal taken from the collector-emitter path.

You can build any logic gate you want by cobbling together a few transistors and
resistors in just the right way. In this section, I look at simple transistor circuits for five
gate types — NOT, AND, OR, NAND, and NOR — and I present projects to show you
how to build three of them: NOT, NAND, and NOR.
Project 1: A transistor NOT gate circuit
A NOT gate simply inverts its input. If the input is HIGH, the output is LOW, and if the input is
LOW, the output is HIGH. Such a circuit is easy to build, using a single transistor and a pair of
resistors. Figure 3-1 shows the schematic.

FIGURE 3-1: A transistor NOT gate.

The operation of this circuit is simple. The input is connected through resistor R2 to the
transistor’s base. When no voltage is present on the input, the transistor turns off. When the
transistor is off, no current flows through the collector-emitter path. Thus, current from the supply
voltage (Vcc in the schematic, typically between and ) flows through resistor R1 to the
output. In this way, the circuit’s output is HIGH when its input is LOW.
When voltage is present at the input, the transistor turns on, allowing current to flow through the
collector-emitter circuit directly to ground. This ground path creates a shortcut that bypasses the
output, which causes the output to go LOW.
In this way, the output is HIGH when the input is LOW and LOW when the input is HIGH.
Project 1 shows how to assemble a simple transistor NOT gate on a solderless breadboard. For
this project, a normally open push button is used as the input. When the button isn’t pressed, the
input is LOW and the output is HIGH, which causes the LED to light. When you press the button,
the input goes HIGH, the output goes LOW, and the LED goes out. The assembled project is shown
in Figure 3-2 .
FIGURE 3-2: A transistor NOT gate assembled on a breadboard (Project 31).

Project 2: A Transistor NOT Gate


In this project, you build a simple NOT gate by using a bipolar transistor. A NOT gate, as shown
in Table 3-1 , is also known as an inverter. It simply reverses the logic level of its input. So, if the
input is HIGH, the output of a NOT gate is LOW. If the input is LOW, the output is HIGH.

TABLE 3-1 NOT Gate Truth Table

0 1

1 0

The input to this gate is controlled by a push-button switch (SW1). When the switch is open, the
input is LOW. When the switch is closed, the input is HIGH.
The output from this gate is sent through an LED, so the LED is on when the output is HIGH and
off when the output is LOW.
Parts
Four AA batteries
One four AA battery holder (RadioShack 2700391)
One small solderless breadboard (RadioShack 2760003)
One normally open DIP breadboard push button
One NPN switching transistor, 2N2222A or similar (RadioShack 2761617)
One 5mm red LED (RadioShack 2760209)
Two resistors (brown-black-red)
Three short jumper wires

Steps
1. Insert the transistor Q1.
Collector: G7
Base: G6
Emitter: G5
2. Insert resistors R1 and R2.
: E7 to F7
: E6 to F6
3. Insert LED1.
Cathode (short lead): Ground bus
Anode (long lead): J7
4. Insert SW1.
The pins should be inserted in B4, D4, B6, and D6 such that the switch opens and
closes across rows 4 and 6.
5. Insert the jumper wires.
1: Positive bus to A4
2: Positive bus to A7
3: Ground bus to J5
6. Connect the batteries.
Red lead: Positive bus.
Black lead: Ground bus.

Project 3: A transistor AND gate circuit


A two-input AND gate produces a HIGH output if both of its inputs are HIGH. You can create a
two-input AND gate by using two transistors and three resistors, as shown in Figure 3-3 . In this
circuit, the output current must flow from the Vcc supply voltage through the collector-emitter
circuits of both transistors to reach the output. Thus, current will flow to the output only if both of
the transistors are on.
FIGURE 3-3: A transistor AND gate.

The bases of both transistors are fed through R2 and R3 from the two inputs. Thus, if both inputs
are HIGH, current will flow through the base-emitter path of both transistors, turning both
transistors on and allowing current to flow through to the output. If either input is LOW, the
corresponding transistor turns off, and the output goes LOW.

Project 4:A transistor NAND gate circuit


A two-input NAND gate produces a LOW output if both of its inputs are HIGH. You could create a
NAND gate by combining the circuits shown in Figure 3-1 and Figure 3-3 so that the output from
the AND gate is used as input to the NOT gate, but that combination would require three
transistors. It’s easy enough to create a NAND gate by using just two transistors, as shown in
Figure 3-4 .

FIGURE 3-4: A transistor NAND gate.

This NAND gate circuit is almost identical to the AND gate circuit shown in Figure 3-3 , earlier
in this chapter. The only difference is that instead of connecting the output to the emitter of the
second transistor, the output is obtained before the collector of the first transistor. If both of the
inputs are HIGH, both of the transistors will conduct through their collector-emitter paths, which
creates a short circuit to ground. This causes the current to bypass the output altogether, which in
turn causes the output to go LOW.
If either transistor turns off, however, the supply current can’t flow through the transistors to
ground, so it flows through the output circuit instead. Thus, the output is HIGH if either one of the
inputs is LOW. If both inputs are HIGH, the output is LOW.
Project 4 shows how to assemble a simple transistor NAND gate on a solderless breadboard.
Normally open push buttons are used for the two inputs. The LED will be on until you press both
of the push buttons. This action causes both inputs to go HIGH, which causes the output to go LOW
and the LED to go dark. The completed project is shown in Figure 3-5 .

FIGURE 3-5: A two-transistor NAND gate on a breadboard (Project 32).

Project 5: A Transistor NAND Gate


In this project, you build a simple NAND gate using a pair of bipolar transistors. As shown in
Table 3-2 , the output of a NAND gate is LOW if both inputs are HIGH; otherwise, the output is
HIGH.

TABLE 3-2 NAND Gate Truth Table


Input A Input B Output

0 0 1

0 1 1

1 0 1

1 1 0

The inputs in this project are provided by two breadboard-mounted push buttons, and the output is
indicated by an LED. The LED is lit unless both of the push buttons are pressed.
Parts
Four AA batteries
One four AA battery holder (RadioShack 2700391)
One small solderless breadboard (RadioShack 2760003)
Two normally open DIP breadboard push buttons
Two NPN switching transistors, 2N2222A or similar (RadioShack 2761617)
One 5mm red LED (RadioShack 2760209)
Three resistors (brown-black-red)
Five short jumper wires

Steps
1. Insert the transistors Q1 and Q2.
Lead Q1 Q2

Collector G7 G11

Base G6 G10

Emitter G5 G9

2. Insert resistors R1, R2, and R3.


: E7 to F7
: E6 to F6
: E10 to F10
3. Insert LED1.
Cathode (short lead): Ground bus
Anode (long lead): J7
4. Insert SW1.
The pins should be inserted in B4, D4, B6, and D6 such that the switch opens and
closes across rows 4 and 6.
5. Insert SW2.
The pins should be inserted in B8, D8, B10, and D10 such that the switch opens
and closes across rows 8 and 10.
6. Insert the jumper wires.
1: Positive bus to A4
2: Positive bus to A7
3: Positive bus to A8
4: Ground bus to J9
5: I5 to I11
7. Connect the batteries.
Red lead: Positive bus
Black lead: Ground bus

Project 6: A transistor OR gate circuit


A two-input OR gate produces a HIGH output if either of its inputs is HIGH or both of its inputs
are HIGH. Figure 3-6 shows a schematic for an OR gate created with two transistors and three
resistors.

FIGURE 3-6: A transistor OR gate.

In the OR gate circuit; the supply voltage is connected separately to the collector of each
transistor. Then the emitters of both transistors are connected to the output. That way, if voltage is
applied to the base of either one of the transistors, that transistor will turn on and pass current
through to the output.
Thus, the output is HIGH if one input is HIGH or both inputs are HIGH. The output is LOW only if
both inputs are LOW.

Project 7:A transistor NOR gate circuit


A NOR gate is an inverted OR gate. If at least one of the inputs is HIGH, the output is LOW. If both
inputs are LOW, the output is HIGH.
Figure 3-7 shows a schematic for a NOR gate. This circuit is similar to the circuit shown in Figure
3-6 , earlier in this chapter, except that the output is connected to the collector of both transistors
and the emitter of each transistor is connected to ground. If either one of the transistors is on,
current from Vcc will be short-circuited to ground, bypassing the output. As a result, the output
will be HIGH only when both inputs are LOW. If either input is HIGH or both inputs are HIGH,
the output will be LOW.

FIGURE 3-7: A transistor NOR gate.

You can build a two-transistor NOR gate by following the steps outlined in Project 33. As with the
other projects in this chapter, Project 33 uses normally open push buttons to control the input
circuits. When power is applied to this circuit, both inputs initially will be LOW, and the output
will be HIGH. Pressing either one of the switches causes that switch’s input to go HIGH, which in
turn causes the output to go LOW. The assembled project is shown in Figure 3-8 .
FIGURE 3-8: A two-transistor NOR gate on a breadboard (Project 33).

Project 7: A Transistor NOR Gate


In this project, you build a simple NOR gate using a pair of bipolar transistors. As Table 3-3
shows, the output of a NOR gate is HIGH if both inputs are LOW. If either input is HIGH, the
output is LOW.

TABLE 3-3 NOR Gate Truth Table


Input A Input B Output

0 0 1

0 1 0

1 0 0

1 1 0

The inputs in this project are provided by two breadboard-mounted push buttons, and the output is
indicated by an LED. The LED is lit unless at least one of the push buttons is pressed.
Parts
Four AA batteries
One four AA battery holder (RadioShack 2700391)
One small solderless breadboard (RadioShack 2760003)
Two normally open DIP breadboard push buttons
Two NPN switching transistors, 2N2222A or similar (RadioShack 2761617)
One 5mm red LED (RadioShack 2760209)
Three resistors (brown-black-red)
Six short jumper wires

Steps
1. Insert the transistors Q1 and Q2.
Lead Q1 Q2

Collector G7 G11

Base G6 G10

Emitter G5 G9

2. Insert resistors R1, R2, and R3.


: E7 to F7
: E6 to F6
: E10 to F10
3. Insert LED1.
Cathode (short lead): Ground bus
Anode (long lead): J7
4. Insert SW1.
The pins should be inserted in B4, D4, B6, and D6 such that the switch opens and
closes across rows 4 and 6.
5. Insert SW2.
The pins should be inserted in B8, D8, B10, and D10 such that the switch opens
and closes across rows 8 and 10.
6. Insert the jumper wires.
1: Positive bus to A4
2: Positive bus to A7
3: Positive bus to A8
4: Ground bus to J5
5: Ground bus to J9
6: I7 to I11
7. Connect the batteries.
Red lead: Positive bus
Black lead: Ground bus

You might also like