Skip to main content

setup pin mode and read, write to PCF8574 pins

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 0x20 and 0x21 are the I2C addresses p1 = pcf8574_io.PCF(0x20) 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.digital_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(“p4”, “OUTPUT”) p1.digital_write(“p4”, “HIGH”) print(p1.digital_read(“p4”))

# you can read and write up to 8 boards at the same time just make sure you ech board has a different address p2.pin_mode(“p7”, “OUTPUT”) p2.digital_write(“p7”, “LOW”) print(p2.digital_read(“p7”))

Change Log

0.0.1 (27/10/2020)

  • First Release

0.0.2 (27/10/2020)

  • Second Release

0.0.3 (28/10/2020)

  • third Release

  • fix bugs

0.0.4 (30/10/2020)

  • fourth Release

  • fix bugs

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

pcf8574_io-0.0.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file pcf8574_io-0.0.4.tar.gz.

File metadata

  • Download URL: pcf8574_io-0.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

File hashes

Hashes for pcf8574_io-0.0.4.tar.gz
Algorithm Hash digest
SHA256 26a42898893d5c383218f2b90994dbd36d2f0e0e2c91c4948d42538af5580acb
MD5 f5f90ea6ba25c6da812296e09c7e1c21
BLAKE2b-256 5380891c55be63f0552d2df5f4f5d17bb621f455e0a9353a52ad32e995c02164

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page