16-bit I/O expander, which you can add up to 8 of to a single I2C bus.
#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.
}
Please login to post comments.
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.