Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using Shift registers with Arduino

Contents

As we all know, Arduino or any micro-controllers that exist have a limited number of pins. An Arduino has 14 digital pins. So, what if we had to control 7 LEDs or drive something else using it? We would have to use 7 individual digital pins. That is quite a big number of pins. Today, we will learn to overcome that problem by making use of the power of Shift Registers! By using a shift register we can give away 7 or more digital outputs using only 3 Arduino digital pins. The circuit is a bit big, the working principals are a little complex too. But this is a really useful technique that totally is worth knowing.

What is a Shift Register?

The Shift Register is a type of sequential logic circuit that can be used for the storage or the transfer of binary data. Shift registers hold the data in their memory which is moved or “shifted” to their required positions on each clock pulse. The register is loaded with serial data, one bit at a time, with the stored data being available at the output in parallel form. Explaining Shift registers is quite a complex task as there are university courses on it and it is quite a broad topic. So, if you are interested in understanding how this thing works, I strongly recommend you to check the following links out in sequential order.

If the above video has been removed, a backup as been made for archive purposes: Click Here. 

If the above video has been removed, a backup as been made for archive purposes: Click Here. 

Shift Register SN74HC595

For our tutorial today, we will be using the SN74HC595 IC.

The SN74HC595 devices contain an 8-bit, serial-in, parallel-out shift register that feeds an 8-bit D-type storage register. The storage register has parallel 3-state outputs. Separate clocks are provided for both the shift and storage register. The shift register has a direct overriding clear (SRCLR) input, serial (SER) input, and serial outputs for cascading. When the output-enable (OE) input is high, the outputs are in the high-impedance state.

SN74HC595 Pinout

Circuit DiaGRAM

The circuit may look a little messy and complex, but don’t worry. It actually isn’t when you start implementing.

The Code

				
					int DS_pin = 8;
int STCP_pin = 9;
int SHCP_pin = 10;

void setup() {
pinMode(DS_pin,OUTPUT);
pinMode(STCP_pin,OUTPUT);
pinMode(SHCP_pin,OUTPUT);

writereg();
}

boolean registers[8];

void writereg() {
digitalWrite(STCP_pin, LOW);

for (int i = 7; i>=0; i--) {
digitalWrite(SHCP_pin, LOW);
digitalWrite(DS_pin, registers[i] );
digitalWrite(SHCP_pin, HIGH);
}

digitalWrite(STCP_pin, HIGH);
}

void loop() {
for(int i = 0; i<8; i++) {
registers[i] = HIGH;
delay(1000);
writereg();
}

for(int i = 7; i>0; i--) {
registers[i] = LOW;
delay(1000);
writereg();

}
}
				
			

How The Code Works

This code basically turns on all the LED one by one, then turn them off again one by one. 
Working procedure of the register and the code is a little complex but really awesome when you understand it. 

Basically, while keeping the SHCP pin low, we set the each of the bits by shooting pulses. After setting all the 8 bits or sending all the pulses to the DS pin, we give a pulse at the STCP pin which executes our given configuration of the bits and the LEDs are turned on as desired. We turn on LEDs one by one, then turn them off one by one again. 

To understand the process more clearly, we recommend you to watch this video referenced above, “How Shift Registers Work” It explains the process in a very detailed manner. 

If you have implemented the project shown here, Congratulations! You are no longer limited to the beginner and basic circuits and projects. Cheers!

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top