PCF8575 I2C IO Expander

16-bit I/O expander, which you can add up to 8 of to a single I2C bus.

Hello World!

#include "mbed.h"
#include "PCF8575.h"

PCF8575 IO(p9, p10, 0x40);  // sda, scl, address
int var;                    // integer variable

int main() {
        IO.write(0xFFFF);   // All outputs goes high. 
        IO.write(0x00FF);   // Only the lower half goes high.
        wait(5);
        var = IO.read();    // Read the inputs on the PCF8575 to integer. 
}

/media/uploads/Lerche/pcf8575_connections.gif

Library

PCF8575 Library

Reference

PCF8575 Datasheet

PCF8575 Eagle library





3 comments:

07 Jul 2011

Hi there.

Have you tested this device and it works correctly? I am getting a bit of a confused data back and forth.

For example, if I write 0x1 and read back the values I get a 0x100 if I write a 0x102 and read back I get a 0x201 If I write a 0x205 and read back I get a 0x502 If I write a 0x50A and read back I get a 0xA05 now it gets stranger if I write a 0xA15 and read back I get a 0x50A if I write a 0x52A and read back I get a 0xA05

Is this a little endian, big endian thing? I am not sure what to make of it or how to make this work.

Especially when I write a 0x1 and read back a 0x100.

Comments are appreciated.

25 Aug 2011

Try updating library.

Thanks Lerche

15 Sep 2011

May I know how do I determine the value of R1 and R2 in the circuit?

Thanks.

Edit: Got the resistor value from the I2C page, it's 2K2 ohm.