greetings, i posted this to bring together all the tidbits on this device, of which i've become interested in. theres alot of scattered info all over. please, smart people correct/add to this. this device will add 8 inputs or outputs. datasheet here http://www.ti.com/lit/ds/symlink/pcf8574.pdf
older library here, i couldnt get this to work but someone maybe able to update it Arduino Forum
playground stuff Arduino Playground - I2CPortExpanderAndKeypads
tutorial to get you up and running Tutorial: Arduino and the I2C bus – Part Two | tronixstuff.com
to understand i2c please see Mr. Gammon's tutorial here http://www.gammon.com.au/forum/?id=10896
they call it knightrider, i call it cylon Tutorial 18: Two Wire Arduino Knight Rider Circuit and Sketch Using PCF8574 I/O expander IC
reading as inputs, have a care though, its not Wire.receive anymore its Wire.read http://practicalmaker.com/blog/arduino-reading-pcf8574-pins-inputs
this code works for reading inputs, but i believe the schematic is wrong http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574
be nice to have a library for this, something im going to tinker with, but alas, i am not, dare i say, up to the task "yet". but please if someone skilled is bored and has time on their hands. just remember to control the outputs, 0= all on, 0x255= all off, 0x254= port0 on (11111110), although, i get erratic behavior if i send BIN instead of HEX. as far as addressing goes, the datasheet answers this, image attached, eg pins A0-A2 grounded = address 0x20.
thank you for your time. more will be added as i learn/find it. edit-added my i2c test shield.
reading an input as a test..
#include<Wire.h>
byte x=0;
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
Wire.requestFrom(0x21,1);
if(Wire.available()) //If the request is available
{
x=Wire.read(); //Receive the data
}
Serial.println(x);
delay(10000);
}
//inputs shorted to ground
if port0 is on and all off x will equal 254.
** maybe a better option is the MCP23017. Nick Gammon has extensive documentation here http://www.gammon.com.au/forum/?id=10896 and adafruit has libraries already in place. i ordered a few of these the other day. happy port expanding!