Shift Register 74HC595 with Arduino – Examples & Code
Interfacing 74HC595 Shift Register with Arduino - Examples Code for LED Chaser, Heartbeat LED, PWM Brightness, LED Wave Effect Larson Scanner
- Suitable forB.Tech/Diploma Arduino students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
Overview
In this project, we will be interfacing
74HC595 Shift Register
with
Arduino
. We will use 74HC595 with Arduino and
multiple LEDs
to create few example projects.
The Arduino provides a good number of I/O pins, making it ideal for controlling various components like LEDs, sensors, and servos. However, as your project grows, you might run out of pins to use. A
shift register
like the
74HC595
offers an elegant solution by expanding the number of
I/O pins
available. This IC allows control of up to
8 output pins
using just
3 input pins
, and by daisy-chaining multiple 74HC595 registers, you can control an even larger number of outputs. This technique, known as
bit-shifting
, is powerful for managing LEDs, displays, or any scenario requiring numerous output pins.
This tutorial shows how to connect the 74HC595 shift register to an Arduino and use it in
five fun projects
:
LED Chaser, Heartbeat LED Effect, PWM Brightness Control, LED Wave Effect
, and
LED Larson Scanner
. These projects demonstrate how flexible the 74HC595 is, letting you create
cool light patterns
and smoothly adjust LED brightness using PWM.
Components Needed
Arduino Board
74HC595 Shift Register
8 LEDs
8 Resistors (220Ω recommended)
Breadboard
Jumper Wires
74HC595 Shift Register
Fig: 74HC595 Shift Register
The 74HC595 is an
8-bit serial-in
parallel-out shift register
. It is a popular IC used for expanding the number of output pins on a microcontroller. By using a shift register like the 74HC595, you can
control multiple outputs
, such as
LEDs
, with just a few pins from your microcontroller. This makes it ideal for projects where the microcontroller’s pins are limited but
multiple outputs
are needed.
The 74HC595 has
8 output pins
(
Q0–Q7
) that can be controlled using only t
hree control pins
from a microcontroller. Additionally, multiple 74HC595 ICs can be daisy-chained together to control even more outputs while still using the same three control pins. Refer to
74HC595 Datasheet
for more information.
How Does the 74HC595 Work?
The 74HC595 works by receiving
data serially
(one bit at a time) and then outputting it
parallelly
(
to 8 output pins
) after the data is latched. It uses a process called
bit-shifting
to move the data into its internal register. Here’s the basic process:
Data Loading
:
The microcontroller sends a serial data stream (0s and 1s) to the
SER
(Data) pin of the 74HC595.
Each bit of data is shifted into the shift register on the rising edge of the
SRCLK
(Shift Register Clock) pin.
Data Latching
:
Once all 8 bits of data are sent, the
RCLK
(Register Clock, also called Latch) pin is triggered. This transfers the data from the shift register to the output register, making it appear on the output pins (Q0–Q7).
Output Control
:
The
OE
(Output Enable) pin allows you to control whether the outputs are active. By default,
OE
is tied to the ground to keep the outputs active.
By repeating this process, the 74HC595 can control its outputs or daisy chain with additional ICs for more outputs.
74HC595 Pinout and Their Functions
The 74HC595 has 16 pins, and their functions are as follows:
Fig: 74HC595 Pinout
Pin
Function
Q1
Output pin 1 (parallel output)
Q2
Output pin 2 (parallel output)
Q3
Output pin 3 (parallel output)
Q4
Output pin 4 (parallel output)
Q5
Output pin 5 (parallel output)
Q6
Output pin 6 (parallel output)
Q7
Output pin 7 (parallel output)
GND
Ground
Q7’
Serial out (used for daisy-chaining another 74HC595 IC)
MR
Master Reset (active low, used to reset all outputs to 0)
SRCLK
Shift Register Clock (triggers the shift of the bits in the shift register)
RCLK
Register Clock (latches the shifted data to the output pins)
OE
Output Enable (active low, enables or disables the outputs)
SER
Serial Data Input (receives serial data from the microcontroller)
Q0
Output pin 0 (parallel output)
VCC
Supply voltage (2V to 6V)
How to Use the 74HC595 with a Microcontroller
Using the 74HC595 with a microcontroller, such as an Arduino, is straightforward. The microcontroller controls the
SER
SRCLK
, and
RCLK
pins of the 74HC595 to shift and latch the data.
Fig: 74HC595 Microcontroller Connection
Basic Connections
:
Connect the
SER
pin of the 74HC595 to a data output pin of the microcontroller.
Connect the
SRCLK
pin to a clock output pin of the microcontroller.
Connect the
RCLK
pin to a latch output pin of the microcontroller.
Connect the
OE
pin to GND (or a PWM pin if brightness control is needed).
Connect the
MR
pin to VCC (to disable reset functionality).
Connect LEDs or other devices to the output pins (Q0–Q7).
Data Transmission
:
Send a byte of data (8 bits) to the
SER
pin one bit at a time.
Pulse the
SRCLK
pin for each bit to shift it into the register.
After all 8 bits are shifted, pulse the
RCLK
pin to latch the data to the outputs.
Controlling Outputs
:
The data sent determines which outputs (Q0–Q7) are HIGH or LOW. For example:
Sending
0b00000001
lights up Q0.
Sending
0b10000000
lights up Q7.
Daisy-Chaining Multiple 74HC595 ICs
To control more than 8 outputs, you can daisy-chain multiple 74HC595 ICs. The
Q7’
pin of one IC is connected to the
SER
pin of the next IC. The
SRCLK
and
RCLK
pins of all ICs are connected in parallel to the microcontroller.
This setup allows you to shift data through the chain of ICs, enabling control of a virtually unlimited number of outputs.
Applications of the 74HC595
LED Displays
: Control multiple LEDs or 7-segment displays.
Matrix Keypads
: Read inputs from a keypad using fewer pins.
Motor Control
: Drive multiple relays or motors.
Digital Indicators
: Control binary or decimal indicators.
By combining the 74HC595 with a microcontroller, you can efficiently manage projects with multiple outputs while conserving precious I/O pins.
Hardware Connection between 74HC595 and Arduino
Since we are going to use 74HC595 with an Arduino and many LEDs, we will connect the components on a breadboard as per the following circuit diagram.
Here is the connection detail:
74HC595 to Arduino:
Pin 11 (SRCLK) to Arduino pin 2 (clockPin)
Pin 12 (RCLK) to Arduino pin 3 (latchPin)
Pin 14 (SER) to Arduino pin 4 (dataPin)
Pin 8 (GND) to Arduino GND
Pin 16 (Vcc) to Arduino 5V
Pin 10 (SRCLR) to Arduino 5V
Pin 13 (OE) to Arduino GND
LEDs to 74HC595:
Connect each LED anode to Q0-Q7 (pins 15, 1, 2, 3, 4, 5, 6, 7) through a resistor.
Connect all LED cathodes to the GND rail.
There will be so many connections, so it requires many jumper wires and a good breadboard. As shown above, properly connect the components on the breadboard. I used an Arduino Nano instead of an Arduino UNO Board.
Project 1: LED Chaser using 74HC595 & Arduino
An LED chaser creates a visual effect where LEDs light up one by one in a sequential pattern, resembling a chasing motion. Variations can include adjusting the speed of the sequence or reversing the direction of the chase for added dynamics.
We can use the following code with Arduino to develop LED Chaser circuit using 74HC595.
int
latchPin
=
;
// Latch pin of 74HC595 is connected to Digital pin 3
int
clockPin
=
;
// Clock pin of 74HC595 is connected to Digital pin 2
int
dataPin
=
;
// Data pin of 74HC595 is connected to Digital pin 4
void
setup
(
)
{
// Set all the pins as output
pinMode
(
latchPin
OUTPUT
)
;
pinMode
(
clockPin
OUTPUT
)
;
pinMode
(
dataPin
OUTPUT
)
;
}
void
loop
(
)
{
for
(
int
i
=
;
i
<
;
i
++
)
{
// Move the single high bit (1) from left to right
int
value
=
<<
i
;
updateShiftRegister
(
value
)
;
delay
(
)
;
// Adjust delay for speed
}
for
(
int
i
=
;
i
>
;
i
--
)
{
// Move the single high bit (1) from right to left
int
value
=
<<
i
;
updateShiftRegister
(
value
)
;
delay
(
)
;
// Adjust delay for speed
}
}
void
updateShiftRegister
(
int
value
)
{
// Begin the shifting process
digitalWrite
(
l
In this project, we will be interfacing
74HC595 Shift Register
with
Arduino
. We will use 74HC595 with Arduino and
multiple LEDs
to create few example projects.
The Arduino provides a good number of I/O pins, making it ideal for controlling various components like LEDs, sensors, and servos. However, as your project grows, you might run out of pins to use. A
shift register
like the
74HC595
offers an elegant solution by expanding the number of
I/O pins
available. This IC allows control of up to
8 output pins
using just
3 input pins
, and by daisy-chaining multiple 74HC595 registers, you can control an even larger number of outputs. This technique, known as
bit-shifting
, is powerful for managing LEDs, displays, or any scenario requiring numerous output pins.
This tutorial shows how to connect the 74HC595 shift register to an Arduino and use it in
five fun projects
:
LED Chaser, Heartbeat LED Effect, PWM Brightness Control, LED Wave Effect
, and
LED Larson Scanner
. These projects demonstrate how flexible the 74HC595 is, letting you create
cool light patterns
and smoothly adjust LED brightness using PWM.
Components Needed
Arduino Board
74HC595 Shift Register
8 LEDs
8 Resistors (220Ω recommended)
Breadboard
Jumper Wires
74HC595 Shift Register
Fig: 74HC595 Shift Register
The 74HC595 is an
8-bit serial-in
parallel-out shift register
. It is a popular IC used for expanding the number of output pins on a microcontroller. By using a shift register like the 74HC595, you can
control multiple outputs
, such as
LEDs
, with just a few pins from your microcontroller. This makes it ideal for projects where the microcontroller’s pins are limited but
multiple outputs
are needed.
The 74HC595 has
8 output pins
(
Q0–Q7
) that can be controlled using only t
hree control pins
from a microcontroller. Additionally, multiple 74HC595 ICs can be daisy-chained together to control even more outputs while still using the same three control pins. Refer to
74HC595 Datasheet
for more information.
How Does the 74HC595 Work?
The 74HC595 works by receiving
data serially
(one bit at a time) and then outputting it
parallelly
(
to 8 output pins
) after the data is latched. It uses a process called
bit-shifting
to move the data into its internal register. Here’s the basic process:
Data Loading
:
The microcontroller sends a serial data stream (0s and 1s) to the
SER
(Data) pin of the 74HC595.
Each bit of data is shifted into the shift register on the rising edge of the
SRCLK
(Shift Register Clock) pin.
Data Latching
:
Once all 8 bits of data are sent, the
RCLK
(Register Clock, also called Latch) pin is triggered. This transfers the data from the shift register to the output register, making it appear on the output pins (Q0–Q7).
Output Control
:
The
OE
(Output Enable) pin allows you to control whether the outputs are active. By default,
OE
is tied to the ground to keep the outputs active.
By repeating this process, the 74HC595 can control its outputs or daisy chain with additional ICs for more outputs.
74HC595 Pinout and Their Functions
The 74HC595 has 16 pins, and their functions are as follows:
Fig: 74HC595 Pinout
Pin
Function
Q1
Output pin 1 (parallel output)
Q2
Output pin 2 (parallel output)
Q3
Output pin 3 (parallel output)
Q4
Output pin 4 (parallel output)
Q5
Output pin 5 (parallel output)
Q6
Output pin 6 (parallel output)
Q7
Output pin 7 (parallel output)
GND
Ground
Q7’
Serial out (used for daisy-chaining another 74HC595 IC)
MR
Master Reset (active low, used to reset all outputs to 0)
SRCLK
Shift Register Clock (triggers the shift of the bits in the shift register)
RCLK
Register Clock (latches the shifted data to the output pins)
OE
Output Enable (active low, enables or disables the outputs)
SER
Serial Data Input (receives serial data from the microcontroller)
Q0
Output pin 0 (parallel output)
VCC
Supply voltage (2V to 6V)
How to Use the 74HC595 with a Microcontroller
Using the 74HC595 with a microcontroller, such as an Arduino, is straightforward. The microcontroller controls the
SER
SRCLK
, and
RCLK
pins of the 74HC595 to shift and latch the data.
Fig: 74HC595 Microcontroller Connection
Basic Connections
:
Connect the
SER
pin of the 74HC595 to a data output pin of the microcontroller.
Connect the
SRCLK
pin to a clock output pin of the microcontroller.
Connect the
RCLK
pin to a latch output pin of the microcontroller.
Connect the
OE
pin to GND (or a PWM pin if brightness control is needed).
Connect the
MR
pin to VCC (to disable reset functionality).
Connect LEDs or other devices to the output pins (Q0–Q7).
Data Transmission
:
Send a byte of data (8 bits) to the
SER
pin one bit at a time.
Pulse the
SRCLK
pin for each bit to shift it into the register.
After all 8 bits are shifted, pulse the
RCLK
pin to latch the data to the outputs.
Controlling Outputs
:
The data sent determines which outputs (Q0–Q7) are HIGH or LOW. For example:
Sending
0b00000001
lights up Q0.
Sending
0b10000000
lights up Q7.
Daisy-Chaining Multiple 74HC595 ICs
To control more than 8 outputs, you can daisy-chain multiple 74HC595 ICs. The
Q7’
pin of one IC is connected to the
SER
pin of the next IC. The
SRCLK
and
RCLK
pins of all ICs are connected in parallel to the microcontroller.
This setup allows you to shift data through the chain of ICs, enabling control of a virtually unlimited number of outputs.
Applications of the 74HC595
LED Displays
: Control multiple LEDs or 7-segment displays.
Matrix Keypads
: Read inputs from a keypad using fewer pins.
Motor Control
: Drive multiple relays or motors.
Digital Indicators
: Control binary or decimal indicators.
By combining the 74HC595 with a microcontroller, you can efficiently manage projects with multiple outputs while conserving precious I/O pins.
Hardware Connection between 74HC595 and Arduino
Since we are going to use 74HC595 with an Arduino and many LEDs, we will connect the components on a breadboard as per the following circuit diagram.
Here is the connection detail:
74HC595 to Arduino:
Pin 11 (SRCLK) to Arduino pin 2 (clockPin)
Pin 12 (RCLK) to Arduino pin 3 (latchPin)
Pin 14 (SER) to Arduino pin 4 (dataPin)
Pin 8 (GND) to Arduino GND
Pin 16 (Vcc) to Arduino 5V
Pin 10 (SRCLR) to Arduino 5V
Pin 13 (OE) to Arduino GND
LEDs to 74HC595:
Connect each LED anode to Q0-Q7 (pins 15, 1, 2, 3, 4, 5, 6, 7) through a resistor.
Connect all LED cathodes to the GND rail.
There will be so many connections, so it requires many jumper wires and a good breadboard. As shown above, properly connect the components on the breadboard. I used an Arduino Nano instead of an Arduino UNO Board.
Project 1: LED Chaser using 74HC595 & Arduino
An LED chaser creates a visual effect where LEDs light up one by one in a sequential pattern, resembling a chasing motion. Variations can include adjusting the speed of the sequence or reversing the direction of the chase for added dynamics.
We can use the following code with Arduino to develop LED Chaser circuit using 74HC595.
int
latchPin
=
;
// Latch pin of 74HC595 is connected to Digital pin 3
int
clockPin
=
;
// Clock pin of 74HC595 is connected to Digital pin 2
int
dataPin
=
;
// Data pin of 74HC595 is connected to Digital pin 4
void
setup
(
)
{
// Set all the pins as output
pinMode
(
latchPin
OUTPUT
)
;
pinMode
(
clockPin
OUTPUT
)
;
pinMode
(
dataPin
OUTPUT
)
;
}
void
loop
(
)
{
for
(
int
i
=
;
i
<
;
i
++
)
{
// Move the single high bit (1) from left to right
int
value
=
<<
i
;
updateShiftRegister
(
value
)
;
delay
(
)
;
// Adjust delay for speed
}
for
(
int
i
=
;
i
>
;
i
--
)
{
// Move the single high bit (1) from right to left
int
value
=
<<
i
;
updateShiftRegister
(
value
)
;
delay
(
)
;
// Adjust delay for speed
}
}
void
updateShiftRegister
(
int
value
)
{
// Begin the shifting process
digitalWrite
(
l
Technologies used
Hardware components
- Arduino
- Relay
- Servo
Software & tools
- Arduino IDE
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.