
Fig. 1
Arduino 74HC595 Serial Shift Register Interfacing
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.

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++) { byteOut(i); delay(200); } } //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); pulseCLK(); j = j >> 1; } pulseCS(); // latch byte } void pulseCLK() { digitalWrite(CLK, HIGH); digitalWrite(CLK, LOW); } void pulseCS() { digitalWrite(LATCH, HIGH); digitalWrite(LATCH, LOW); }
- Web Master
- Gen. Electronics
- YouTube Channel
- Arduino Projects
- Raspberry Pi & Linux
- PIC18F2550 in C
- PIC16F628A Assembly
- PICAXE Projects
- Bristol VA/TN
- Environmentalism
- US Constitution
- Religious Themes
- Religion Archive 1
- Connect-Program Arduino and a MM5451 LED Display Driver
- Arduino and a MM5451 LED Display Driver YouTube
- Programming Arduino and the 74HC595 Serial Shift Register
- Programming Arduino and the 74HC595 Serial Shift Register YouTube
- Arduino Analog to Digital Conversion Voltmeter
- Arduino ADC Voltmeter YouTube video
- Arduino Pulse-Width Modulation Digital to Analog Conversion
- Arduino PWM to ADC YouTube video
- Zero-Crossing Detectors Circuits and Applications
- Zero-Crossing Detectors YouTube video
- Comparator Theory Circuits Tutorial
- Analog Solar Panel Battery Charge Controller
- Better Arduino Rotary Encoder Sensor
- Simple 3-Wire MAX6675 Thermocouple ADC Arduino Interface
- Comparator Theory Circuits Tutorial
- Constant Current Circuits with the LM334
- LM334 CCS Circuits with Thermistors, Photocells
- LM317 Constant Current Source Circuits
- TA8050P H-Bridge Motor Control
- All NPN Transistor H-Bridge Motor Control
- Basic Triacs and SCRs
- Comparator Hysteresis and Schmitt Triggers
- All NPN Transistor 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