ShiftPi is the easiest way to work with 74HC595
shift registers on your Raspberry Pi.
This is a fork of Mignev's Arduino style library.
Which in turn was inspired by this article: Can you move over? The 74HC595 8 bit shift register
import shiftpi
s = shiftpi.ShiftPi()
# set pin-1 on
s.write(0, True)
# or
s.write(0, s.HIGH)
# or
s.up(0)
# set all on (or off)
s.write(s.ALL, True)
# set pin-8 off
s.write(7, False)
# or
s.down(0)
HIGH
- pin onLOW
- pin offALL
- all pins (instead of 0-7)
Default pins mappings are as follows:
Name | GPIO | 74HC959 |
---|---|---|
SER | 27 | 14 |
RCLK | 24 | 12 |
SRCLK | 22 | 11 |
Different pins can be set with the init options. Additional chips can be set here too.
s = ShiftPi(ser_pin=27, rck_pin=24, sck_pin=22, num_registers=2)
- Raspberry Pi
- Python 2.7+
ShiftPi uses PyGPIO to expose multiple backends. By default it uses a native interface to the linux GPIO driver. It can also utilise RPi.GPIO or WiringPi.
Get shiftpi
source and install it:
git clone https://git.mk2es.com.au/gwillz/shiftpi
cd shiftpi/
sudo python setup.py install
See LICENSE