Created
July 20, 2018 00:49
-
-
Save n0bisuke/de8d6250dcefef6bd3c56df3d0550ac4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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