Im familiar with the i2c protocol and have been trying to adapt it to the arduino Wire library. I have found many examples on how to read or write to the device via the i2c bus, however, i cannot figure out how to read AND write. The PCF8575 has 16 I/O pins. I have 8 switches and 8 LED's. I want to read from the 8 switches (on P0-P7) and write to the 8 LEDS (on P10-P17).
The datasheet says that the data transfer needs to take place in byte pairs where byte 1 relates to port 0 (P0-P7) and byte 2 relates to port 1 (P10-P17). If this is the case, how does one read from only P0-P7 and write to only P10-P17?
http://focus.ti.com/lit/ds/symlink/pcf8575c.pdf
See page 2.
Any ideas or code examples from others who have done this?
THANKS!
Well, I want the LED's to respond to the switches. So if i press switch 0 located on P00, LED 0 on P10 turns on. When i release switch 0, LED 0 turns off. The way i see it, if i have to write to all 16 pins, i could potentially be writing a 0 (low voltage) to pin that goes to Vcc through one of the switches (which is being pressed) and short the power source. That doesnt seem right!