i2c read

Good. I hereby ask for help I am developing a project with an Arduino + expander PCF8574 ... wanted to read the data from the output port of the expander and I am not getting .. I have this code..

/* Test program for PCF8574 I2C I/O expander - Blinks all ports low then high. by Ford */

include "Wire.h"

define expander B0100000 // Address with three address pins grounded.

// Note that the R/W bit is not part of this address.

void setup() { Wire.begin(); Serial.begin(9600);

}

void loop() { Serial.println("LED OFF"); expanderWrite(B00000000); Serial.print("Read: "); Serial.println(expanderRead(), BIN); delay(1000); Serial.println("LED ON"); expanderWrite(B00100000); Serial.print("Read: "); Serial.println(expanderRead(), BIN); delay(1000); }

void expanderWrite(byte _data ) { Wire.beginTransmission(expander); Wire.send(_data); Wire.endTransmission(); }

byte expanderRead() { byte _data; Wire.requestFrom(expander, 1); if(Wire.available()) { _data = Wire.receive(); } return _data; } thanks for attention

SOmewhere on this page - http://www.gammon.com.au/forum/?id=10896 - is an I2C sniffer that can see if you use the right address, and a lot more information about I2C..

Rob

My big problem is that the plot is only 7 bits when writing to the PCF8574 there is no problem seems to read but when is the last bit is one and not know how it goes