1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| // Inclure les librairies
#include <LiquidCrystal.h>
#include "Keypad.h"
#include "Key.h"
// Initialiser les librairies avec les chiffres des fiches de l'interface
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
// Début du programme
void setup() {
// Initialiser l'afficheur
lcd.begin(16, 2);
// Afficher un message
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
char Code = "780D";
scanf("Saisir le code", Code, "%s");
if (Code != "780D"){
lcd.print("Code incorrect");
}
else
{
Serial.println(Code);
lcd.print("Code correct");
}
} |
Partager