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