Go Down

Topic: unnofficial guide to PCF8574 i/o expansion i2c bus (Read 3485 times) previous topic - next topic


Mar 18, 2013, 05:13 pm Last Edit: Mar 20, 2013, 03:26 pm by grendle Reason: 1
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 http://arduino.cc/forum/index.php?topic=109340.0
playground stuff http://playground.arduino.cc/Main/I2CPortExpanderAndKeypads
tutorial to get you up and running http://tronixstuff.wordpress.com/2010/10/29/tutorial-arduino-and-the-i2c-bus-part-two/
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 http://startingelectronics.com/beginners/start-electronics-now/tut18-two-wire-arduino-knight-rider/
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..
Code: [Select]

byte x=0;

void setup()

void loop()
   if(Wire.available())     //If the request is available
       x=Wire.read();       //Receive the data

//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!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131