#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
byte colPins[COLS] = {4,5,6}; // Pins connected to C1, C2, C3, C4
byte rowPins[ROWS] = {0,1,2,3}; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String x = "";
void setup() {
lcd.begin(16,2);
lcd.setCursor(0, 0);
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey();
if ((key != NO_KEY) && (key != "#") && (key != "*")){
x += key;
lcd.print(x);
}
lcd.setCursor(0,0);
}
//It seems that as the code gets more complicated, the check method should be
//programmed in a more complicated way as well in order to solve the judgetime issue