74HC595 connected to Arduino
Fig. 1

Arduino 74HC595 Serial Shift Register Interfacing

by Lewis Loflin


Here we look into connecting a 74HC595 8-bit serial shift register with 8-bit latch to an Arduino Microcontroller. Fig. 1 shows the internal configuration.

While Arduino has built in commands for serial output by writing our own we can port the basic program to other platforms such as the Raspberry Pi.

// use just k instead of !k 
// for common cathode displays.
void   byteOut(byte j)   {
  byte k;
  for(int i=0; i < 8; i++)   {
    k = j & 0x01;
    digitalWrite(DATA, k); 
    digitalWrite(CLK, HIGH);
    digitalWrite(CLK, LOW); 
    j = j >> 1;
  // latch byte
  digitalWrite(LATCH, HIGH);
  digitalWrite(LATCH, LOW);

Above is our serial shift subroutine byteOut(). It's nothing more than a for loop, a bitwise AND, and right-shift that sets or clears the DATA pin, pulses (HIGH then LOW) the shift clock, then after doing that 8 times pulses (HIGH then LOW) the latch pin. Here we shift out the least significant bit first.

74HC595 connected to 8 LEDs.
Fig. 2

Fig. 2 shows the LED connections. The LED pattern is simply a reproduction of the binary pattern shifted into the 8-bit register. In this case we simply count in binary from 0-255 right to left.

// Count 0-255 74HC595

#define DATA 8 // 74HC595 pin 14
#define LATCH 9 // 74HC595 pin 12
#define CLK 10 // 74HC595 pin 11

void setup()   {
  pinMode(DATA, OUTPUT);  
  pinMode(LATCH, OUTPUT);
  pinMode(CLK, OUTPUT);
  digitalWrite(DATA, 0); 
  digitalWrite(LATCH, 0);
  digitalWrite(CLK, 0);
} // end setup

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

} //end loop

// use just k instead of !k 
// for common cathode displays.
void   byteOut(byte j)   {
  byte k;
  for(int i=0; i < 8; i++)   {
    k = j & 0x01;
    digitalWrite(DATA, k); 
    j = j >> 1;
  pulseCS(); // latch byte

void pulseCLK()   {
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW); 

void pulseCS()   {
  digitalWrite(LATCH, HIGH);
  digitalWrite(LATCH, LOW);




Electronics Homepage
TA8050P H-Bridge Motor Control

Optical Isolation of H-Bridge Motor Controls YouTube
Optical Isolation of H-Bridge Motor Controls

Opto-Couplers Theory and Circuits YouTube
Opto-Isolated Transistor Drivers for Micro-Controllers

All NPN Transistor H-Bridge Motor Control YouTube
All NPN Transistor H-Bridge Motor Control

Pulse-Width Modulation Tutorial YouTube
Pulse-Width Modulation Tutorial

PIC12F683 Microcontroller and Circuits YouTube
PIC12F683 Microcontroller and Circuits