/**************************************************/
/**************************************************/
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
char message[6];
char key;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {23, 22, 21, 19};
byte colPins[COLS] = {18, 5, 4, 2};
int i=0;
Keypad keypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
const String password = "1234";
String input_password;
void lireString(){
char key = keypad.getKey();
if (key) {
Serial.print(key);
if (key == '*') {
input_password = ""; // reset the input password
} else if (key == '#') {
if (input_password == password ) {
Serial.println();
Serial.println("The password is correct");
} else {Serial.println();
Serial.println("The password is incorrect");
}
input_password = ""; // reset the input password
} else {
input_password += key; // append new character to input password string
}
}
}
void setup(){
Serial.begin(9600);
Serial.println("Saisir votre password");
}
void loop(){
lireString();
}