Last active
April 21, 2018 09:07
-
-
Save slendidev/b7635c10b4535dea9d2e8a408ab1ba64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Password.h> | |
#include <Keypad.h> | |
#define led 5 | |
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','B'}, | |
{'*','0','#','D'} | |
}; | |
byte rowPins[ROWS] = {13, 12, 11, 10}; | |
//connect to the row pinouts of the keypad | |
byte colPins[COLS] = {9, 8, 7, 6}; | |
//connect to the column pinouts of the keypad | |
//initialize an instance of class NewKeypad | |
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); | |
Password password = Password("1234"); | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(5, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
char customKey = customKeypad.getKey(); | |
if (customKey){ | |
Serial.print(customKey); | |
password.append(customKey); | |
if (password.evaluate()) { | |
password.reset(); | |
Serial.println("CODE IS CORRECT"); | |
digitalWrite(5, HIGH); | |
delay(1000); | |
digitalWrite(5, LOW); | |
} else { | |
Serial.println("CODE IS NOT CORRECT"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment