Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Library for communication with PCF8574 IO expander over I2C

Project description

PCF8574

This is a Python library for use with the PCF8574 I2C IO expander chip. It abstracts the 8 bit IO port as a Python list, and allows the read/writing of individual pins or the whole port at once.

Installation

The library depends on the smbus-cffi package. You may need to apt-get install libffi-dev if you're on a debian based system. Otherwise, simply:

pip install pcf8574

Usage

In [1]: from pcf8574 import PCF8574

In [2]: i2c_port_num = 1

In [3]: pcf_address = 0x20

In [4]: pcf = PCF8574(i2c_port_num, pcf_address)

In [5]: pcf.port
Out[5]: [True, True, True, True, True, True, True, True]

In [6]: pcf.port[0] = False

In [7]: pcf.port
Out[7]: [False, True, True, True, True, True, True, True]

In [8]: pcf.port = [True, False, True, False, True, False, True, False]

In [9]: pcf.port
Out[9]: [True, False, True, False, True, False, True, False]

In [10]: pcf.port[7]
Out[10]: False

In [11]: pcf.port[6]
Out[11]: True

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 pcf8574, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size pcf8574-0.1.3.tar.gz (3.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