Good day,
I am actually looking to make sure, I us correctly my PCF8574 extender port with Arduino.
It look to work but I am not convinced it work well.
For exemple when I do this
for(int i=1;i>6;i++){
PCF_27.write(i,1);
delay(50);
Serial.print(PCF_27.read(i));
delay(50);
}
It return sometime 1 and sometime 0, while I should always get 1.
From this link Arduino Playground - HomePage, I can see this
// adjust addresses if needed
PCF8574 PCF_38(0x38); // add switches to lines (used as input)
PCF8574 PCF_39(0x39); // add LEDs to lines (used as output)
Why it need to have two address? In my case, I only need output.
I connect A0,A1 and A2, to 3V3, then the ADDR should be 0x27. But I read somewhere
8 digital I/O bits and can be set to addresses 0x20-0x27 and 0x38-0x3F respectively
So 0x20 is inout and 0x27 output?
Why in the above exemple, it use 0x38 and 0x39? Shoud not use 0x3f?
Finaly, I found this library
He use pinMode()
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, INPUT);
Why the Arduino Playground do not define the pin state?
Then I would be happy to know more about the best practice with the PCF8574.
Many thank for your support and enjoy your week-end with Arduino!