Skip to main content

Use the 74HC595 Shift Register with a Raspberry Pi

Project description


Allows for easy use of the 74HC595 Shift Register with a Raspberry Pi

Pypi version Python version License Downloads


$ pip install pi74HC595

Initialize pi74HC595 class

You should install the stockfish engine in your operating system globally or specify path to binary file in class constructor

from pi74HC595 import pi74HC595
import RPi.GPIO as gpio

shift_register = pi74HC595()

This package uses gpio.BOARD (pin numbering as opposed to GPIO numbering)

There are some default settings:

def __init__(
        DS: int = 11,
        ST: int = 13,
        SH: int = 15,
        daisy_chain: int = 1,

Pin Numbering

Raspberry Pi Pinout 74HC595 Pinout
Raspberry Pi Pinout 74HC595 Pinout

Both Vcc and MR require 5V

You will likely need to change the Raspberry Pi pins during initialization.

shift_register = pi74HC595(7, 37, 22)

These can also be set after initialization with...

shift_register.set_ds(7) # Any GPIO pin on Raspberry Pi

Daisy Chaining

If you are daisy chaining multiple 74HC595s then you can set daisy_chain to your number of 74HC595s during initialization.

shift_register = pi74HC595(7, 37, 22, 2)

shift_register = pi74HC595(daisy_chain = 13)

# etc

This can also be done after initialization with...

shift_register.set_daisy_chain(3) # Any positive int


Set Values with a List:

Will accept both Integers (1 and 0 only) as well as Boolean values (True and False)

shift_register.set_by_list([0, 1, 0, 1, 1, 1, 0, 0])
shift_register.set_by_list([False, True, False,...])

Set Values with an Integer:

This was created with the intent to send a single 1 or 0 for on or off, but can also function with a larger int as it converts to binary


shift_register.set_by_int(12) #1100
shift_register.set_by_int(9999) #1111100111

Set Values with a Boolean:

Can send a single True or False for on or off.


Clear All Current Values:

Sets each value to off (0)


Get All Current Values:

Returns the current values

[0, 0, 0, 0, 0, 0, 0, 0]

Good 74HC595 Tutorials

It took me awhile to finally understand how the 74HC595 worked since I had no prior hardware experience. These are the tutorials I used to understand the shift register.

Great but with Arduino

Good and with Raspberry Pi



MIT License. Please see License File for more information.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pi74HC595, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pi74HC595-1.2.0-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pi74HC595-1.2.0.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page