Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- #include <Password.h>
- #define rows 4
- #define cols 3
- #define keyLED 11
- #define correctLED 12
- #define wrongLED 13
- char keys[rows][cols] = {
- {'1','2','3'},
- {'4','5','6'},
- {'7','8','9'},
- {'*','0','#'}
- };
- byte rowPins[rows] = {2,3,4,5};
- byte colPins[cols] = {6,7,8};
- Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,rows,cols);
- Password password = Password("1234");
- void setup() {
- pinMode(keyLED,OUTPUT);
- pinMode(correctLED,OUTPUT);
- pinMode(wrongLED,OUTPUT);
- }
- void loop() {
- byte counter = 0;
- char key = keypad.getKey();
- if(key != NO_KEY && key != '#' ) {
- blinkLED(keyLED);
- password.(key);
- counter++;
- }
- if( key=='#')
- {
- if(password.evaluate()) {
- blinkLED(correctLED);
- }
- else {
- blinkLED(wrongLED);
- }
- password.reset();
- }
- }
- void blinkLED(byte ledPin) {
- digitalWrite(ledPin,HIGH);
- delay(200);
- digitalWrite(ledPin,LOW);
- }
Add Comment
Please, Sign In to add comment