PCF8574 driver to set pin mode, read and write digital signal 3.3v
Project description
Python driver for PCF8574 8bit IO Expander board Developed for the Raspberry Pi, requires the python-smbus2 package to access the I2C bus.
Tested on raspberry pi 3b plus with two PCF8574 boards.
First install smbus2 using: pip install smbus2
Usage Example:
import pcf8574_io
# You can use up to 8 PCF8574 boards # the board will start in input mode # the pins are HIGH in input mode p1 = pcf8574_io.PCF(0x20)
# You can use multiple boards with different addresses #p2 = pcf8574_io.PCF(0x21)
# p0 to p7 are the pins name # INPUT or OUTPUT is the mode p1.pin_mode(“p0”, “INPUT”) print(p1.read(“p0”))
# You can write and read the output pins # use HIGH or LOW to set the pin, HIGH is +3.3v LOW is 0v p1.pin_mode(“p7”, “OUTPUT”) p1.write(“p7”, “LOW”) print(p1.read(“p7”))
# Additional you can do the following p1.set_i2cBus(1) p1.get_i2cBus() print(p1.get_pin_mode(“p7”)) # returns string OUTPUT, INPUT print(p1.is_pin_output(“p7”)) # returns boolean True, False print(p1.get_all_mode()) # returns list of all pins [“OUTPUT”,”INPUT”,…etc]
/n/nhttps://github.com/ahmed9378/pcf8574_io
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pcf8574_io-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f089eafc670427358f86a7654ca2caac18915b43f4b9bdf7c2d63ec3082b6a59 |
|
MD5 | 4de0525ae1b2031f52ffe7a72c870d9a |
|
BLAKE2b-256 | 013cdc344151f6a705dc530b761d394ae9daebac4cb2b12648b483271024f5a1 |