#include <Wire.h> // Library for I2C communication
#include "Keypad_I2C.h" // Library for Keypad
#define I2CADDR 0x38 // PCF8574's I2C Address
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
// Define the keymaps. The blank spot (lower left) is the space character.
char numberKeys[ROWS][COLS] = {
{ '1','2','3','A' },
{ '4','5','6','B' },
{ '7','8','9','C' },
{ '*','0','#','D' }
};
char* keypadMap = makeKeymap(numberKeys);
byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
Keypad_I2C keypad(keypadMap, rowPins, colPins, sizeof(rowPins), sizeof(colPins), 0x20, PCF8574);
void setup(){
Serial.begin(38400);
Wire.begin( );
keypad.begin( );
}
char key;
void loop(){
if (key = keypad.getKey()) {
Serial.print("keypad = ");
Serial.println(key);
}
}
pcf8574_pcf8574a.pdf