//.....................Arduino Keypad 4x4.............. //.................Download Keypad.h library........... #include #include const byte ROWS = 4; const byte COLS = 4; 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}; byte colPins[COLS] = {5, 4, 3, 2}; Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); char resset; char customKey; char entre[5]; int count =0; char mdp[] = "123BC"; void setup(){ pinMode(12, OUTPUT); Serial.begin(9600); } void loop(){ customKey = customKeypad.getKey(); if (customKey){ //Serial.println(customKey); entre[count] = customKey; count++; Serial.println(entre); resset = customKey; if (resset == '#'){ count = 0; } if (count >= 5) { count = 0; } // la fonction strcmp compare deux chaines de caractères, on vérifie s'ils correspondent if (!strcmp(entre, mdp)){ // on allume la sortie 12 si le code est bon digitalWrite(12, HIGH); } else if (strcmp(entre, mdp)){ // on allume la sortie 12 si le code est bon digitalWrite(12, LOW); } } }