#include <Keypad.h>
const int ROWS = 1;
const int COLS = 5;
char keys[ROWS][COLS] = {
{' ', 'l', 'u', 'd', 'r'}
// {'1', '2', '3', '4', '5'}
};
byte R_PINS[ROWS] = {3};
byte C_PINS[COLS] = {8, 7, 6, 5, 4};
Keypad keypad = Keypad(makeKeymap(keys), R_PINS, C_PINS, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey();
if(key){
if(key == ' '){
Serial.println("Space");
}else if(key == 'l'){
Serial.println("Left");
}
else if(key == 'u'){
Serial.println("Up");
}
else if(key == 'd'){
Serial.println("Down");
}
else if(key == 'r'){
Serial.println("Right");
}
}
}