74HC595 8 bit Shift Register

Have you ever wondered how people made their projects controlling tons of LEDs with just a single Arduino? Controlling all the LEDs individually requires a lot of pins. So, now I am going to introduce you to shift register. In this tutorial the shift register that we are going to use is 74HC595, 8 bit shift register. By using shift register, you expanded a lot of output pins from your Arduino, that is the best part!

Okay, you might wondering, what is the shift register that I have mentioned. Now, I am going to briefly cover some basic information on shift register before proceed to 74HC595 IC. Shift register consists of arrangement of flip flops and used in applications involved storage and transfer of data in digital system. Shift register can have either serial or parallel inputs and outputs. Four basic configurations of shift register are Serial-In, Serial-Out,  Serial-In, Parallel-Out, Parallel-In, Serial-Out, and Parallel-In, Parallel-Out.

sr5The difference between serial and parallel data transfer is that serial transfer data bit by bit whereas parallel transfer data simultaneously. The data transfer rate for parallel is faster than serial, eg, 8 bits of data in serial requires eight time intervals to fully transfer data, but for parallel with 8 data lines only requires one time interval. However, the down side of using parallel data transfer is that it cost more than serial because of the number of data lines required.

A clock is used to provide an uniform and synchronous timing for the shift register to work. Next, I am going to introduce another new term which is latch. A latch actually works as a storage used to store data in digital electronic system.

74HC595 IC

What I really like about 74HC595 shift register is that it expands eight more pins with only three pins from Arduino. It can be used to control outputs such as LED, relays, 7 segment or even make yourself a serial LCD. You can try to search around for serial LCD with 74HC595. It further reduce the pins used to control LCD in 4 bit mode, from 7 pins to 3 pins!!  Besides that, you can chain shift register to control even more outputs with only three control pins.

Datasheet for 74HC595, available here

Some features of 74HC595:

– 8 Bit Serial Input

– 8 Bit Serial and Parallel Output

– Storage Register with 3 State Output

Pin Diagram and Description for 74HC595:

Pin Diagram
Pin Description (Click to enlarge)

For Q0 to Q7, this is the eight output pin of your shift register. SHCP is the clock input to your shift register, while STCP is the latch for the register. DS is the serial data input. MR, master reset is used to reset the shift register, in this case, we are going to connect it to 5V since we don’t need to reset it. Besides that, to enable the output, you need to connect OE to GND.

Timing diagram for 74HC595

To control the shift register in your program, send a low signal to your shift register. Next, shift 8 bits of data in 8 period of clock. Then, send a high signal to latch out the 8 bits of data. The reason to send a LOW signal before transfers all the data and a HIGH signal after complete transfers all the data is because the latch is positive edge triggered. On the positive edge of latch signal, all the serial data will be latch out. here is a function in Arduino which ease the job of shifting data, which is shiftOut(). We will discuss it on the code part.

Another analogy of mine on shift register is that data is like people who are queueing, the clock control the people enter one at a time, and the latch is eight gates to allow the people pass through the gate.

Let us start working with shift register and Arduino.

How to connect your shift register
Potentiometer to control speed of data update
Overall set up of circuit on a breadboard
8 LEDs to display output


Sample code to try with 74HC595 Shift Register

#define clock 9
#define latch 10
#define data 11
#define pot A0

byte value=0;

void setup()

void loop()
 for(int i=0;i<=255;i++)

In the setup() function, you need to set the pinMode for clock, latch and serial data as output. A potentiometer is connected to control the speed of data update.

As mentioned previously, first we need to reset the latch pin. Then shift in the data to shift register with shiftOut function, only then you set the latch pin to output the serial data.


– Datapin is the pin to output each bit, clockpin is used to toggle for clock signal. Order allows you to select order of output, either Most Significant Bit (MSB) or Least Significant Bit (LSB) first. The last parameter is the value to shift out.

Video demo:

Start working with shift register and Arduino now and share the project of yours using shift register.

4 thoughts on “74HC595 8 bit Shift Register

  1. I was googling this a few days ago and was going to blog abut the 74hc595 because I will be using it for my POV project how funny 🙂

  2. thank you sir for your detailed tutorial, but i don’t get it why the LEDs blink randomly??? what is exactly happening in the register that they blink randomely?

    1. Hi Amir,

      The LED does not blink randomly, it is running as a 8 bit counter. The leftmost is the LSB while the rightmost is the MSB.

      A potentiometer is used to control the speed of counter.

      Hope it helps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s