#include <LiquidCrystal.h>
#include <Keypad.h> // Keypad library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// 4x4 Keypad
const byte ROWS = 4; // 4 Rows
const byte COLS = 4; // 4 Columns
// Keypad
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Keypad Arduino
byte rowPins[ROWS] = {14, 15, 16, 17}; // Keypad 4 Rows: Row0, Row1, Row2, Row3
byte colPins[COLS] = {18, 19, 20, 21}; // Keypad 3 Columns: Column1, Column2, Column32,Column1
// Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
String messaggi[] = {
"Hello world",
"Ciao mondo",
"Hola mundo",
"Hallo welt",
"Bonjour le monde"
};
#define PULL_UP 8
bool puls_up;
bool puls_press;
void setup() {
lcd.begin(16, 2);
pinMode(PULL_UP, INPUT);
}
byte jj = 0;
int pausa = 0;
void loop() {
lcd.setCursor(0, 0);
char key = keypad.getKey();
lcd.print(key);
puls_up = digitalRead(PULL_UP);
// if ((millis()-pausa) > 1000) {
if ((puls_up == 0) && (puls_press == 0)) {
puls_press = 1;
// pausa = millis();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(messaggi[jj]);
jj++;
}
else if (puls_up == 1)
puls_press = 0;
if (jj > 4)
jj = 0;
}
void setup(){
Serial.begin(9600);
}
void loop(){
// Keypad
// NO_KEY
if (key != NO_KEY){
Serial.println(key);
}
}