PCF8574 I2c Digital IO Expander Fast Easy Usage
PCF8574 I2c Digital IO Expander Fast Easy Usage
by xxreef
Can read and write digital value with only 2 wire (perfect for ESP-01).
I try to simplify the use of this IC, with a minimal set of operation.
You can find my library here. Place the PCF8574 library folder your /libraries/
folder.
To download.
You may need to create the libraries subfolder if its
Click the DOWNLOADS button in the top right corner, your first library.
rename the uncompressed folder PCF8574.
Restart the IDE.
Check that the PCF8574 folder contains
PCF8574.cpp and PCF8574.h.
Step 2: Usage
Constructor: you must pas the address of i2c (to check the adress use this guide I2cScanner)
PCF8574(uint8_t address);
for esp8266 if you want specify SDA e SCL pin use this:
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, INPUT);
pcf8574.pinMode(P2, INPUT);
So to read all analog input in one trasmission you can do (even if I use a 10millis debounce time to prevent too
much read from i2c):
PCF8574.digitalWrite(P1, HIGH);
or:
PCF8574.digitalWrite(P1, LOW);
You can also use interrupt pin: You must initialize the pin and the function to call when interrupt raised from
PCF8574.
// Function interrupt
void keyPressedOnPCF8574();
Step 7: Thanks