Pages: [1]   Go Down
Author Topic: unnofficial guide to PCF8574 i/o expansion i2c bus  (Read 1272 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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!


* pcf8574end.jpeg (65.08 KB, 540x313 - viewed 78 times.)

* DSC05541.png (621.98 KB, 648x486 - viewed 94 times.)
« Last Edit: March 20, 2013, 09:26:18 am by grendle » Logged

Pages: [1]   Go Up
Jump to: