Skip to content

Instantly share code, notes, and snippets.

@n0bisuke
Created July 20, 2018 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n0bisuke/de8d6250dcefef6bd3c56df3d0550ac4 to your computer and use it in GitHub Desktop.
Save n0bisuke/de8d6250dcefef6bd3c56df3d0550ac4 to your computer and use it in GitHub Desktop.
#include <Keypad.h>
const byte n_rows = 4;
const byte n_cols = 4;
char keys[n_rows][n_cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte colPins[n_rows] = {D3, D2, D1, D0};
byte rowPins[n_cols] = {D7, D6, D5, D4};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols);
void setup(){
Serial.begin(115200);
}
void loop(){
char myKey = myKeypad.getKey();
if (myKey != NULL){
Serial.print("Key pressed: ");
Serial.println(myKey);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment