How to use 74HC595 Shift Register with Arduino?

Table of Contents

In this project, I will talk about Shift Registers, one of the popular Shift Register ICs – 74HC595 and finally how to use the 74HC595 Shift Register with Arduino and the benefits of this interface.

Introduction

Normally, consider a small application where you want to drive 8 LEDs with the help of Arduino (or any microcontroller). This application, though a very basic and simple one, would require you to use 8 of the available Input / Output Pins of your Arduino Board: one for each LED.

Now consider a slightly advanced project, where your requirements are driving the same 8 LEDs and also doing other stuff like displaying a message or any information on a 16×2 LCD Display or interface a Bluetooth Device to control the LEDs through a smart phone!!!

This type of bigger projects would consume a lot of your I/O Pins on your Arduino Board and there might not be enough pins left for interfacing additional devices.

Here comes the Shift Register IC to the rescue.

 

What is a Shift Register?

A Shift Register is basically a Serial-to-Parallel Converter IC. It basically takes a serial input through a single pin (well, technically you need at least 3 pins, which I will talk about later) and converts it into 8-bit parallel output thus effectively reducing the number of interface pins between a Microcontroller and its output devices.

There are other flavours of shift registers like Serial IN Parallel OUT (the one we are interested in), Serial IN Serial OUT, Parallel IN Serial OUT and Parallel IN Parallel OUT. For more information on Shift Registers, visit SHIFT REGISTERS TYPES AND APPLICATIONS.

In this project, I will be using a Serial IN and Parallel OUT type Shift Register IC called 74HC595.

A Brief Note 74HC595 Shift Register IC

As mentioned earlier, the 74HC595 IC is an 8-bit Serial IN Parallel OUT shift register. It is 16-pin IC available in a wide range of packages like DIP, SOIC, SSOP and TSSOP.

74HC595 Shift Register with Arduino 74HC595 IC

Pin Diagram of 74HC595 Shift Register

The following image shows the Pin Diagram of 74HC595 Shift Register.

74HC595 Shift Register with Arduino Pin Diagram

Pin Description of 74HC595 Shift Register

Following table describes the pins of 74HC595 Shift Register in brief.

Pin Number Pin Name Description
15, 1-7 QA, QB – QH QA – QH (8) Output Pins
8 GND Ground Pin
9 QH’ QH’ Output
10 SRCLR’ Reset Input
11 SRCLK Clock Input
12 RCLK Storage Register Clock Input
13 OE’ Output Enable
14 SER Serial Input
16 VCC Supply Voltage

NOTE: There are several manufacturers of 74HC595 Shift Register IC and the naming convention of each manufacturer may be different. Check out the data sheet based on the manufacturer. The above pin names are from the data sheet provided by Texas Instruments.

How to use 74HC595 Shift Register with Arduino?

Let me build a simple circuit where I will use only three pins of Arduino UNO and control 8 LEDs. This will be possible by using the 74HC595 Shift Register with Arduino.

The three pins of the shift register that are needed to be connected to Arduino are pins 11 (the clock input), 12 (the storage register clock input or simply the latch input) and 14 (the data input).

All the 8 LEDs will be connected to the shift register IC. (more details in the circuit design section).

Circuit Diagram

The following image shows the circuit diagram of interfacing 74HC595 Shift Register with Arduino UNO.

74HC595 Shift Register with Arduino Circuit Diagram

Components Required

  • Arduino UNO
  • 74HC595 Shift Register IC
  • Breadboard
  • 8 X LEDs
  • 8 X 1KΩ Resistors
  • 5V Power Supply
  • Connecting Wires

Circuit Design

First, connect the Serial Input Pin of 74HC595 Shift Register to Pin 4 of Arduino. Then connect the clock and latch pins i.e. pins 11 and 12 of 74HC595 to pins 6 and 5 of Arduino respectively.

74HC595 Shift Register with Arduino Circuit Design

Now, connect 8 LEDs with individual current limiting 1KΩ Resistors to the 8 output pins of 74HC595 IC. Coming to the power supply, connect a separate 5V power supply to 74HC595 IC with common GND to Arduino rather than supplying 5V from Arduino.

Code

The following is a simple code for turning the LEDs ON in a sequence.

 

int latchPin = 5;
int clkPin = 6;
int dataPin = 4;
byte LED = 0;
void setup()
{
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clkPin, OUTPUT);
}
void loop()
{
int i=0;
LED = 0;
shiftLED();
delay(500);
for (i = 0; i < 8; i++)
{
bitSet(LED, i);
Serial.println(LED);
shiftLED();
delay(500);
}
}
void shiftLED()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clkPin, MSBFIRST, LED);
digitalWrite(latchPin, HIGH);
}

 

Working

Let us now try to understand the working of this project. Initially, all the LEDs will be OFF as the byte variable LED is set to 0. Now, each bit is set to 1 using the “bitSet” function and is shifted out using the “shiftOut” function.

Correspondingly, each LED will be turned on in the same sequence. If you want to turn the LED off, you can use the “bitClear” function.

Applications

The 74HC595 Shift Register IC or any similar shift register for that matter can be used in the following applications:

  • LED Control
  • Network Switches
  • Servers
  • Power Infrastructure
  • Industrial Control
  • Electronic Appliances
  • Simple Serial-to-Parallel Data Conversion
  • Capture and Hold Logic
Facebook
Twitter
LinkedIn
Pinterest

Similar Articles & Blogs

Explore similar articles on various electronics and electrical topics – 

Asynchronous Counter

An Asynchronous counter can have 2n-1 possible counting states e.g. MOD-16 for a 4-bit counter, (0-15) making it ideal for use in Frequency Division applications. But it

Learn More >>

Binary Weighted DAC

Digital-to-Analogue Converters, or DAC’s as they are more commonly known, are the opposite of the Analogue-to-Digital Converters we looked at in a previous tutorial. DAC’s convert binary

Learn More >>

R-2R DAC

We saw in the previous tutorial about the binary weighted digital-to-analogue converter that the analogue output voltage is the weighted sum of the individual inputs, and that

Learn More >>

Analogue to Digital Converter

Analogue-to-Digital Converters, (ADCs) allow micro-processor controlled circuits, Arduinos, Raspberry Pi, and other such digital logic circuits to communicate with the real world. In the real

Learn More >>

Transmission Gate

The analogue switch is a solid-state semiconductor switch that controls the transmission path of analogue signals. The open and closed operations of the switch positions

Learn More >>

Binary Adder

Another common and very useful combinational logic circuit which can be constructed using just a few basic logic gates allowing it to add together two

Learn More >>