I have googled how to have a reprogram-able passcode using Keypad.h and Password.h and all I seem to stumble upon is a couple people asking the same thing but none that have anything helpful. right now all I have is some basic code and I want to make sure I have the this feature before I continue with anything else.
#include <Keypad.h>
#include <Password.h>
char* epass;
Password password = Password(epass);
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'},
};
byte rowPins[ROWS] = {7, 12, 11, 9};
byte colPins[COLS] = {8, 6, 10};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte locked;
void setup(){
Serial.begin(9600);
keypad.addEventListener(keypadEvent);
keypad.setDebounceTime(75);
locked = 1;
}
void loop(){
char key = keypad.getKey();
}
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print(eKey);
switch(eKey){
case'#':guessPassword();
break;
default:password.append(eKey);
}
}
}
void guessPassword(){
if (password.evaluate()){
Serial.println("VALID PASSWORD");
locked = 0;
}
else{
Serial.println("INVALID PASSWORD");
password.reset();
locked = 1;
}
}