Recently, I was going through the pile of old projects which I had made when I had just got into electronics. I found a 24 x 6 LED matrix which was my first 'complete' project. A lot of messy wiring, not perfect but it still works fine. At the time I made this project, I never thought about the components which were used, how did they work, etc. I just wanted to complete it as soon as possible and have some fun. And I'm sure there are many like me.
One such component used in the LED matrix was 74HC595 which is a Shift Register. Yet another popular device which is used when you run out of output pins. There are 24 columns which need to be controlled individually which means that you need 24 output pins on the Arduino (or any other microcontroller) which is a lot and makes the wiring messy. That is why shift registers are used. Now we can control 24 rows (or more) by using just 5 pins on the Arduino. Clever, isn't it?
In my previous Instructable, I made an LCD Trainer Kit which won a First Prize in Electronics Tips and Tricks Contest. It got some lovely comments from the people which suggests that the idea of getting back to basics is great.
In this Instructable, let us look at the working of a shift register and at the end build a small kit to see shift register in action.
Let's get back to basics!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Things You Will Need
1x 74HC595 Shift Register
1x 16 pin IC socket
8x 1k resistors
3x 10k resistors
3x Tactile push buttons
1x micro USB breakout board (optional)
Step 2: Know Your Shift Register
The shift register we will be using is 74HC595 which is an 8-bit Tri-state Shift Register i.e. with 8 outputs. Tri (3) states mean that the output can be set to either HIGH, LOW or High Impedance. Let us have a look at the pins of the IC and their function.
Note: Rising Edge - Transition from 0V to 5V (LOW to HIGH)
Falling Edge - Transition from 5V to 0V (HIGH to LOW)
Inputs (Control Pins)
Pin 14 - Serial Data In
Data is fed into the register from this pin. Serial means data is fed in bit by bit.
Pin 13 - Output Enable (OE)
This pin turns the output ON or OFF. It is an active low pin meaning that pulling the pin LOW enables the output. We will be connecting it directly to GND to make the output always ON.
Pin 12 - Storage Register Clock (RCLK)
When this pin is pulled HIGH, the data from the storage register is transferred to the output.
Pin 11 - Shift Register Clock (SRCLK)
A clock signal is provided to this pin. The data from Pin 14 (Serial Data In) is registered only at the rising edge of the clock. In simple words, when the clock signal rises from 0V to 5V, only then the data present at Pin 14 gets stored in the register.
Pin 10 - Shift Register Clear (SRCLR)
It is an active low pin. As the name suggests, when this pin is pulled LOW, it clears all the data from the storage register. We will be connecting it to 5V permanently so that the data is never cleared from the storage register.
Pin 15, Pin 1 to 7 - QA to QH
These are the 8 outputs of the shift register.
Step 3: Putting the Kit Together
In the beginning, I had planned to use a project enclosure box. But since the components used are not panel friendly I decided to go with the perfboard. Plan the layout of components. Be creative in choosing the layout as long as it is sensible.
I used a micro USB breakout board as I will be powering the kit using USB.
The schematic for the build has been attached.
Step 4: Working
Let's get this thing running. We will try to light up LEDs at Q0 and Q1 i.e. 0000 0011
Note: Pushing the button makes that particular pin HIGH (or 1) and leaving the button makes it LOW (or 0).
Steps to be followed:
1. First, data is made 1 (HIGH). Hold down the Data push button. But the data has not been stored in the register yet.
2. The data is stored in the register when the clock signal rises from 0V to 5V i.e. on the Rising Edge. While holding the Data push button, push the Clock push button once as the IC looks for the rising edge only. Now the data is stored in the storage register as 0000 0001. You can now leave the Data push button.
3. To reflect the same in the output, push the Latch button once. You should see the LED of the first bit glowing. Great!
4. We are not done yet. Again hold down the Data push button and press the Clock push button once. Now the old 1 gets shifted to the left by one bit and the newly added 1 takes its place. Now the storage register will look like 0000 0011.
5. Press the latch button to reflect the same in the output.
Now you might be able to understand why shift registers are used. In this case, 8 outputs can be controlled using only one line. Shift registers come in handy when you run out of output pins on the microcontroller.
I have made a stop motion video to make things more clear. Check out the video on YouTube.
Step 5: Have Fun!
Since you now know how a shift register works, you can use it along with Arduino and make an awesome project! Click here to know more interfacing 74HC595 with Arduino.
Thank you for sticking till the end. Hope you all love this project and learned something new today. Let me know if you make one for yourself. Subscribe to my YouTube channel for more upcoming projects.