#include <Keypad.h>
const uint8_t fil = 4; //dim fila
const uint8_t colum = 4; //dim col
//distribución
char teclas[fil][colum] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
// pines correspondientes a las filas
uint8_t colPins[colum] = { 16, 4, 2, 15 };
// pines correspondientes a las columnas
uint8_t filPins[fil] = { 19, 18, 5, 17 };
// crea objeto con los parametros
Keypad teclado = Keypad(makeKeymap(teclas), filPins, colPins, fil, colum);
void setup() {
Serial.begin(9600);
}
void loop() {
char tecla = teclado.getKey(); //obtiene variable
if (tecla) {
Serial.println(tecla);
}
}