This is an Arduino library for the PCA9539, a 16-bit I/O expander chip. It provides a simple interface for controlling the chip's input and output pins over the I2C. The library allows users to configure individual pins as inputs or outputs, set and read their digital states, and control the polarity inversion of each pin. It also offers functions to read and write to all 16 pins simultaneously.
PCA9539(uint8_t address): Constructor that initializes the library with the I2C address of the PCA9539 chip.begin(): Initializes the I2C communication usingWire.begin().reset(): Resets the PCA9539 to a default state: all pins are set as inputs, output registers are low, and polarity inversion is disabled.pinMode(uint8_t pin, uint8_t mode): Configures the specified pin as eitherINPUTorOUTPUT.digitalWrite(uint8_t pin, uint8_t value): Sets the output value of the specified pin toHIGHorLOW.digitalRead(uint8_t pin): Reads the digital value of the specified pin, returningHIGHorLOW.writeGPIO(uint16_t value): Writes a 16-bit value to all output pins simultaneously.readGPIO(): Reads the current state of all input pins and returns a 16-bit value.writePolarityInversion(uint16_t value): Sets the polarity inversion for all pins using a 16-bit value.readPolarityInversion(): Reads the current polarity inversion settings and returns a 16-bit value.
This library is built upon the original work by Nico Verduin in clsPCA9555.
It includes code that has been forked from the PCA9539 project, which can be found at https://github.com/AD0ND/PCA9539, and is licensed under the GNU General Public License.
This library is released under the terms and conditions of the GNU General Public License.