How to Build a Shift Register Circuit with Manual Pushbutton Control
In this project, we are going to show how to build a shift register circuit wired to pushbuttons so that we can manually see how a shift register works.
Even though shift registers are made to work with microcontrollers such as an Arduino, and in the commercial industry, you always see them used with microcontrollers, in this circuit, we take a manual approach so that you can see exactly how a shift register actually works.
Using manual control with pushbuttons is great for demonstration purposes and see how shift registers work for those who are beginners with them.
For this circuit, we will have 5 pushbuttons. These pushbuttons will control the serial data input, the clock line, the latch pin, the output enable pin, and the clear pin.
It will be thoroughly explained below what these pins are and their functions, so don't worry.
Through manual control of the shift register, you will know exactly how they work in a way that using it with microcontrollers can't teach you, because you're actually doing the work yourself.
The shift register we will use is the popular 74HC595 shift register. This IC
can control up to 8 outputs. In this circuit, our output devices will be LEDs. So one 74HC595
can control 8 LEDs on the output side.
- 74HC595 Shift Register
- 13 LEDs
- 8 220Ω resistors
- 5 1KΩ resistors
- 10KΩ resistor
- 5 Pushbuttons
- 47pF capacitor
The 74HC595 shift register is one of the most popular and widely used ones in the electronics industry. One individual 74HC595 can control 8 outputs. This means it can control, for example, 8 LEDs.
The shift register, in total, has 16 pins.
The pinout for the shift register is shown below.
The table below summarizes these pin connections.
|QA-QH||Output pins||Outputs of the shift register|
|VCC (Pin 16)||Power||Positive voltage for the shift register|
|GND (Pin 8)||Power||Ground for the shift register|
|QH' (Pin 9)||Serial Out||Serial out is used to shift data to another 74HC595 shift register|
|Master Reclear, active low||This sets all the bits in the shift register to 0 or off if pulled LOW.|
|Shift Clock (Pin 11)||Shift Register Clock Pin||If pulled HIGH, this shifts all the values in the shift register forward one.|
|Latch Clock (Pin 12)||Stroage Register Lock Pin||When pulled HIGH, it outputs the new shift register values.|
|Output enable, active low||This enables the output when grounded and disables it when high.|
|Serial Data Input (Pin 14)||Input for New Serial Data||This is the input pin for the new serial data.|
The 74HC595 shift register has 8 outputs. This means you can connect up to 8 output devices, such as LEDs or buzzers, to the shift register. The output pins are QA-QH, 8 in total. QA, pin 15, is the first output pin. Next are QB-QH, which are pins 1-7. These output pins do not connect to the arduino microcontroller. Instead, the outputs, which in this case are LEDs, are connected to them.
To provide power to the 74HC595 shift register, we give +5V to VCC and we connect GND to ground on the arduino microcontroller.
To the serial data input pin of the shift register, we connect a pull-down resistor. A pull-down resistor is a resistor that is normally LOW (connected to ground). Since we want the data line to be LOW when we don't press it, we connect it to a pull-down resistor. When pressed, it is pulled HIGH. And this is how we can submit a 1 or HIGH value to the storage register. In order to transmit data into the storage register, you press down on the CLOCK line. If the data serial input is 0 (meaning the pushbutton is unpressed), then a 0 is transmitted into the storage register. If the data serial input is 1 (meaning the pushbutton is pressed), then a 1 is transmitted into the storage register.
The clock pin (pin 11), is the clock for the shift register. The 74HC595 is clock-driven on the rising edge. This means that in order to shift bits into the storage register of the shift register, the clock must be high. And bits are transferred in on the rising edge of the clock. So the clock must be HIGH when new data is being driven into the storage register. The clock must be HIGH in order to tranfer bits into the storage register.
The latch pin (pin 12) is a very important pin. This pin takes the data that is stored in the storage register and when driven HIGH, transfers the data to the output. So when we initially transfer in data, it goes into the storage register but does not show up at the output. It only shows up at the output when the latch pin is HIGH. This is when we then we see the LEDs turn on. So the latch pin can be seen as like the final step in the process to seeing our results at the output, which in this case are LEDs.
The CLEAR pin is an active low pin. This means that when it is grounded, all data in the storage register is cleared to 0. In order for this not to happen, we keep it at HIGH, so we connect it to VCC. Since this pin is active low, we want it to be HIGH. So we connect this pin to a pull-up resistor. A pull-up resistor is normally HIGH and only becomes low when the pushbutton is pressed down. When pressed down, this clears the storage register of all 1s, so it sets the storage register to all 0s.
The Output Enable pin allows us to turn on or off all the outputs. Usually, we want this enabled so that there can changes on the output side. If this is disabled, then no output can be turned on. This pin is an active low pin, which means when it is grounded, all output pins are disabled. So normally we keep this pin LOW, so this is why we connect it to a pull-down resistor.
The QH' pin is the serial data output pin. This is the pin we use
to cascade an additional shift register. So instead of being able to switch on 8 outputs, we
can then switch on 16 outputs. How this works is we will take the serial data output pin of the first shift register and connect to the serial data input on the second shift register. This way, the
data from the first shift register feeds directly into the second shift register.
This is how the data cascades into the next. Since we are adding additional shift registers, we leave this pin
unconnected in this circuit.
Manual Shift Register Circuit
The shift register circuit we will build that allows us manual control with pushbuttons is shown
This shift register circuit has pretty basic connections.
First we connect power. So we connect VCC of the shift register to 5V. We connect the ground of the shift register to the power ground. This establishes sufficient power to the shift register.
Next we connect the clock pin (pin 11) to a pull-down resistor.
We connect the latch pin (pin 12) a pull-down resistor.
We connect the serial data input pin to a pull-down resistor.
Since the Output Enable pin is active low, we want it to be LOW. So we connect it to a pull-down resistor.
The CLEAR pin is an active low pin, so we want it to be HIGH. Therefore, we connect it to the 5V power source, through a voltage divider. The top resistor is 1KΩ and the bottom resistor is a 10KΩ resistor. This way, the majority of the voltage falls across the 10KΩ resistor; this ensures that the CLEAR pin is active HIGH. Because the 10KΩ resistor is HIGH, however, the LED will light dimly, but this is fine for demonstration purposes.
Lastly, we connect the LEDs to the output pins, QA - QH. To each of the LEDs, we connect a current-limiting 220Ω resistor.
How this circuit works is that we first transfer bits to the storage register. In order to do this, we need the clock to be HIGH in order to transfer bits to the storage register. If the serial data input line is LOW while we press the clock pushbutton, a 0 is transferred in to the storage register. If the serial data input line is HIGH while we press the clock pushbutton, then a 1 is transferred into the storage register. If you press down the clock pushbutton 8 times while the clock is HIGH, we will transfer 8 1s into the storage register. If we push down 4 times on the serial data input line while the clock is HIGH and 4 times on the clock pushbutton while the serial data input pushbutton is not pressed, this will transfer 11110000 into the storage register.
Now, once you have the data transferred into the storage register, the next step is to latch the data into the output. First, we transferred data into the storage register, but this data does not show up at the output (to the LEDs) until we latch it to the output. So once we have the data transferred to the storage register, we have to latch it. Once we press down on the latch pushbutton, it now goes to output. Now we see the LEDs light up. If the data in the storage register is 11111111, all the LEDs will turn on. If the data is 10101010, every other LED will light up. If the data is 11110000, the first 4 LEDs will light up and the next 4 will be off.
If you want to turn off all the LEDs, you can either press down on the output enable pushbutton or the CLEAR line. This clears all the 1s in the storage register. Next, you have to
press down the latch pin to see all the LEDs turn off. The CLEAR pin and the output enable pin are not the same. The CLEAR clears all the 1s to 0s in the storage register. You can then add 1s
after. The output enable pin permanently shuts off all outputs.