#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'A', 'B', 'C', 'D'},
{'E', 'F', 'G', 'H'},
{'I', 'J', 'K', 'L'},
{'M', 'N', 'O', 'P'}};
byte rowPins[ROWS] = {D4, D3, D2, D1};
byte colPins[COLS] = {D8, D7, D6, D5};
Keypad myKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
int buttons[4][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}};
void setup(){
Serial.begin(115200);
}
void loop(){
char keyPressed = myKeypad.getKey();
int buttons[4][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}};
//buttons[ROWS][COLS] = 1;
if (keyPressed != NULL) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
Serial.print(buttons[i][j]);
}
Serial.println("");
}
}
}
Each column is wired with diodes to each button and each row is wired normally.