TCA9555 is a 16-bit I2C I/O expander from Texas Instruments. It allows the easy addition of 16 I/O ports on any device that supports the I2C bus. This makes it attractive for expanding the number of I/O pins on the standard Arduino platform using ATmega328. Up to eight TCA9555’s can be used on the same I2C bus and thus allowing up to an additional 128 digital pins to be added.

Keith Neufeld had provided a basic C library for PCA9555 in his blog post.TCA9555 is an improved version of PCA9555. Functionally speaking, TCA9555 is identical to PCA9555 and both versions have the same pin-out. So the code for PCA9555 can be used with TCA9555 without any change.

To make it even easier to use, I wrote a C++ Arduino library that can be used with either PCA9555 or TCA9555. The library exposes all the functionalities of the chip.

Here is some sample code demonstrating how this library can be used:

#include <Wire.h>
#include <TCA9555.h>

// intializaing TCA9555, A2 A1 A0 are set to 000.
TCA9555 tca9555(0,0,0);

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  
  //set the pin directions for both ports to 
  //output
  tca9555.setPortDirection(TCA9555::DIR_OUTPUT);
  
  //change P00 (pin 4), P01 (pin 5) and P17 (pin 20) to high.
  tca9555.setOutputStates(1<<8 | 3);
  
  //read back the pin states
  Serial.print(tca9555.getInputStates());
}

void loop()
{
}

Download TCA9555 Library: TCA9555.tar.gz

TCA9555
TCA9555
Be Sociable, Share!