If you want to reproduce the experiments in this video yourself, you will need:-
A solderless breadboard.
An SN74HC595 Shift Register
A 9 pin 220Ω Resistor Pack
An 8-Segment LED array
An Raspberry Pi Pico*
20 jumper cables.
Schematic of Shift Register Demo
Mouseover to Zoom
The SN74HC595 is a commonly used 8-bit serial-in, parallel-out shift register IC. It's especially popular in embedded and microcontroller projects (like Arduino and Raspberry Pi) where you want to control many outputs (like LEDs) using just a few GPIO pins.
Photo of Demo Breadboard
Mouseover to Zoom
Photo of working setup. Note that the Resistor pack (8A221G) in the foreground has only 7 outpins, therefore 3 additional resistors have been added (bottom right) to serve the 3 rightmost LEDs of the 10 LED strip. The leftmost pin of the resistor pack has a lead to Ground on the Pico driving this setup. The three resistors connect to the Ground rail of the breadboard which is also connected to Ground on the Pico driving this setup.
Python Code for Shift Register Demo
1 import machine 2 import utime 3 SER_pin = machine.Pin(16, machine.Pin.OUT, machine.Pin.PULL_DOWN) #SERial data in 4 OCL_pin = machine.Pin(17, machine.Pin.OUT, machine.Pin.PULL_DOWN) #Output CLock 5 OEN_pin = machine.Pin(18, machine.Pin.OUT, machine.Pin.PULL_UP) #Oput ENable 6 ICL_pin = machine.Pin(19, machine.Pin.OUT, machine.Pin.PULL_DOWN) #Input CLock 7 CLR_pin = machine.Pin(20, machine.Pin.OUT, machine.Pin.PULL_UP) #Master CLeaR 8 9 bitlist=[1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0]1011 t=0.11213 #Init14 def InitSR():15 CLR_pin.value(0)16 SER_pin.value(0)17 CLR_pin.value(1)18 OCL_pin.value(1)19 OCL_pin.value(0)202122 InitSR()23 while True:24 for bit in bitlist:25 #Put bit onto serial pin26 SER_pin.value(bit)2728 #Move bit into memory29 ICL_pin.value(1) 30 utime.sleep(t)31 ICL_pin.value(0)3233 OCL_pin.value(1)34 OCL_pin.value(0)3536 InitSR()
How it Works
Here is a line by line description of the code example. Note that the Pin numbers below are GPIO Pin numbers on the Pico - NOT Pin numbers on the Shift Register.
Machine library is imported for Pin control
Time library needed for to make timing delays
Define Serial Pin - Used to input bits to the shift register on GPIO6
Define Output Clock pin
Define Output Enable pin Key details about the OEN pin:
Active LOW: This means the outputs are enabled when OEN is LOW (0).
When OEN is HIGH (1), all outputs (Q0-Q7) go into a high-impedance (Hi-Z) state. This effectively disconnects them from the circuit, which is useful if multiple devices share a data bus.
The OEN pin does not affect the internal data in the shift register or storage register. It only affects whether that data is actually driven onto the output pins.
This is useful for tri-stating the outputs to avoid bus conflicts when multiple devices might be connected to the same lines.
Typical Use:
Connect OEN to GND to always enable the outputs.
Optionally, connect OEN to a microcontroller pin or control logic if you need to dynamically enable or disable the outputs. This is how it is used in this demo program.
Define Input Clock pin
The Input Clock Pin (pin 11) on the 74HC595 shift register is commonly labeled as SHCP or SRCLK (Shift Register Clock). It is responsible for shifting data into the shift register.
Key Function:
On each rising edge (LOW to HIGH transition) of the clock signal on pin 11, the 74HC595:
Shifts the current bits in the shift register one position to the left.
Reads the value present on the Serial Data Input (DS, pin 14) and stores it in the first bit (Q0).
Important Notes:
Only the internal shift register is affected by this clock. The parallel output pins (Q0-Q7) do not change until the latch pin (OCLK, pin 12) is pulsed.
This allows you to shift in a full 8-bit value before updating the outputs all at once.
Define Master Clear pin
The Master Clear pin (pin 10) on a 74HC595 shift register is used to reset (clear) the shift register. Key Properties of the Master Clear (CLR) Pin:
Active LOW: The shift register is cleared when CLR is LOW (0x).
When active, all bits in the shift register are reset to 0, regardless of the clock or data inputs.
This does not affect the output latches (Q0-Q7) unless you also trigger the latch clock (OCL, pin 12). So, to reflect the cleared state on the outputs, you must pulse OCL after clearing.
Define list of bits to be sent to shift register
Define a value for pauses (slows processing to enable it to be seen)
[comment denoting Initialisation routine]
Function Initialising Shift Register
Set Master Clear low to clear Shift Register
Set Serial Pin low
Reset Master Clear high
Set Output Clock high, and then ...
Set Output Clock low to reset the output latches to reflect the cleared shift register.
Call function InitSR to inialise Shift Register
Start of repeat forever loop
Loop to fetch bits from 'bitlist' one at a time
[comment 'put bit onto serial pin']
Set bit value (0 or 1) onto Serial In pin
[comment 'Move bit into memory']
Set Input Clock pin to high denoting need to move bit into shift register (and move existing bits along)
Brief pause (to enable this to be seen)
Set Input Clock pin back to low
Set Output Clock pin high to move (all 8) bits in shift register to output register
Set Output Clock pin back to low
When loop through bitlist isa completed, rerun Initialisation routine ready for next iteration through bitlist
Types of Shift Resigter
There are five main types of shift registers, classified by their input and output data types: Serial-In/Serial-Out (SISO), Serial-In/Parallel-Out (SIPO), Parallel-In/Serial-Out (PISO), Parallel-In/Parallel-Out (PIPO), and a Universal shift register.
Here's a breakdown:
Serial-In/Parallel-Out (SIPO): Data enters serially but is available at the outputs in parallel. This is the type that this tutorial will explain and demonstrate.
Serial-In/Serial-Out (SISO): Data enters and exits the register sequentially, bit by bit.
Parallel-In/Serial-Out (PISO): Data enters in parallel and exits serially.
Parallel-In/Parallel-Out (PIPO): Data enters and exits the register in parallel.
Universal: These registers can be configured as SIPO, PISO, or PIPO, offering flexibilit
Types of SIPO Shift Resigter
A common Serial In/Parallel Out (SIPO) shift register IC is the 74HC595. It's used to control a large number of outputs, like LEDs, because it shifts data serially into the register and then provides parallel outputs. Another example is the 74HC164, also an 8-bit SIPO shift register.
74HC595:
This is a popular 8-bit SIPO shift register. It can be used to control 8 outputs at a time, making it suitable for applications like LED displays, where you need to drive multiple LEDs from a single control signal.
74HC164:
This is another common 8-bit SIPO shift register. Like the 74HC595, it shifts data in serially and outputs it in parallel.
SIPO Shift Registers in General:
These ICs take data in a serial stream (one bit at a time) and then make all the internal storage elements available as parallel outputs. This allows you to control a large number of outputs with a limited number of input pins.
These SIPO shift registers are widely used in digital electronics for various applications, including:
Controlling LEDs: Driving a large number of LEDs with a single serial data line.
Displaying data: Implementing displays, like LED matrix displays.
Interfacing with microcontrollers: Extending the number of output pins available on a microcontroller.
Data transmission: Converting serial data to parallel data for easier processing.
Difference between an SN74HC595N shift register and a SC74HC164N shift register
The SN74HC595N and 74HC164N (sometimes prefixed by "SC" depending on manufacturer) are both 8-bit serial-in shift registers, but they have different features and use cases. Here's a detailed comparison:
π SN74HC595N vs 74HC164N
Feature
SN74HC595N
74HC164N (SC74HC164N)
Type
Serial-in, Parallel-out (SIPO)
Serial-in, Parallel-out (SIPO)
Output Latches
β Yes β includes output latches (storage register)
β No β outputs change immediately with shift
Number of Outputs
8 Q outputs
8 Q outputs
Serial Inputs
1 (SER or DS)
2 (A and B, ANDed together)
Clock Pin
β Yes (SRCLK)
β Yes (CLK)
Latch Pin
β Yes (RCLK β registers output to Qs)
β No latch β outputs directly reflect shift register
Output Enable (OE)
β Yes (active low)
β Not available
Cascading
β Easy via Q7β² (serial out)
β Possible β via Q7 or QH
Use Case
Ideal for driving LEDs or displays with stable output
Simple serial shift register
Functional Differences
SN74HC595N:
74HC164N:
Two registers
Single shift register
One shift register (receives bits via serial input).
One storage register (outputs data when latched).
Outputs reflect the immediate state of the shift register - they update as data is shifted in.
You clock data in, and then latch it out.
Very useful when you want to load new data without flickering or affecting outputs during the shift
No control over when data appears on the outputs.
Summary:
Use SN74HC595N when:
You need stable output control (e.g., LED arrays, 7-segment displays).
You don't need output latching or tri-state outputs.
You need an Output Enable pin for tri-state control.
Use 74HC164N when:
You need a simpler, cheaper shift register.
You want to update all outputs at once.
You're okay with outputs changing as data is shifted in.
The SN74HC595 and SC74HC164N (also known as 74HC164) are both 8-bit serial-in, parallel-out (SIPO) shift registers, but they differ significantly in features and behavior: