Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-74hc595
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-74hc595
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-74hc595
Usage Example¶
import board
import adafruit_74hc595
import busio
import digitalio
import time
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
latch_pin = digitalio.DigitalInOut(board.D5)
sr = adafruit_74hc595.ShiftRegister74HC595(spi, latch_pin)
pin1 = sr.get_pin(1)
while True:
pin1.value = True
time.sleep(1)
pin1.value = False
time.sleep(1)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import time
import board
import busio
import digitalio
import adafruit_74hc595
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
latch_pin = digitalio.DigitalInOut(board.D5)
sr = adafruit_74hc595.ShiftRegister74HC595(spi, latch_pin)
pin1 = sr.get_pin(1)
while True:
pin1.value = True
time.sleep(1)
pin1.value = False
time.sleep(1)
|
adafruit_74hc595
¶
CircuitPython driver for 74HC595 shift register.
- Author(s): Kattni Rembor, Tony DiCola
Implementation Notes¶
Hardware:
“* 74HC595 Shift Register - 3 pack”
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_74hc595.
DigitalInOut
(pin_number, shift_register_74hc595)¶ Digital input/output of the 74HC595. The interface is exactly the same as the
digitalio.DigitalInOut
class, however note that by design this device is OUTPUT ONLY! Attempting to read inputs or set direction as input will raise an exception.-
direction
¶ Direction
can only be set toOUTPUT
.
-
pull
¶ Pull-up/down not supported, return None for no pull-up/down.
-
switch_to_input
(**kwargs)¶ switch_to_input
is not supported.
-
switch_to_output
(value=False, **kwargs)¶ DigitalInOut switch_to_output
-
value
¶ The value of the pin, either True for high or False for low.
-
-
class
adafruit_74hc595.
ShiftRegister74HC595
(spi, latch)¶ Initialise the 74HC595 on specified SPI bus.
-
get_pin
(pin)¶ Convenience function to create an instance of the DigitalInOut class pointing at the specified pin of this 74HC595 device .
-
gpio
¶ The raw GPIO output register. Each bit represents the output value of the associated pin (0 = low, 1 = high).
-