This example demonstrates the use of Arduino IO Abstraction library with an i2c 8574 i2c IO expander chip, in order to receive input from a switch and light an LED. It’s about the most basic example possible that has both input and output. To use this example first download the IoAbstraction library
Devices such as the PCF8574 provide an easy way to expand both input and output capabilities using a single chip, and because it’s on i2c, needs only two pins from the Arduino (SDA and SCL). Further, when used with the IO Abstraction library, it’s almost as easy to use as Arduino pins.
Be very aware before using this chip that it is quasi-bidirectional in that:
First power down the Arduino and build the circuit below.
In the circuit below, we connect the IO device to the power (5V-pin16 and GND-pin8) with a 0.1uF decoupling capacitor near the chip between the power rails. Also note that we must select an address that the chip answers on using A0-A3. Notice that the LED must be connected from 5V to the pin through a resistor, this is the only way it will work, as this chip cannot source very much current, but it can sink a lot more.
To find your i2c device address use this i2c address scanner, this sketch will tell you every address on which it finds an i2c chip.
Click here to get the source for this example, which is also included in the examples section of the library.