Password Library

Hi everyone!

I have one question: Is it possible use 2 or more passwords in the “Password Library”?

Because I want to create 3 correct password. I pressed in keypad the password, then I pressed “", to confirm. Put I want to confirm the 3 password with "”. And I don’t can to do this. Help, please?

My code:

#include <Keypad.h> 
#include <Password.h> 
#include <Stepper.h> 

const byte ROWS = 4; 
const byte COLS = 3; 
char key[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 mykeypad = Keypad( makeKeymap(key), rowPins, colPins, ROWS, COLS );


Password key0 = Password( "123" ); 
Password key1 = Password( "456" ); 
Password key2 = Password( "789" ); 

const int totalstepps = 64; 
Stepper mystepper(totalstepps, 9,10,11,12);

void setup() {
  mykeypad.addEventListener(putpassword);
  mystepper.setSpeed(300); 
}

void loop() {
  mykeypad.getKey();
}


void putpassword(KeypadEvent eKey) {
  switch (mykeypad.getState()) {
    case PRESSED:
      switch (eKey) {
        case '*': confirmpassword(); key0.reset(); break;
        case '*': confirmpassword(); key1.reset(); break;
        case '*': confirmpassword(); key2.reset(); break;
        case '#': key0.reset(); break;
        default: key0.append(eKey);
    }
  }
}


void confirmpassword() {
  if (key0.evaluate()) {
    for (int i = 0; i < 32; i++) {
      mystepper.step(7);
    }
    delay(1000);
    for (int j = 0; j < 32; j++) {
      mystepper.step(-7);
    }
  }
}

Is it possible use 2 or more passwords in the "Password Library"?

Yes.

You can't have 3 cases with the same value ('*'). You can, in the one case, call three functions. Or call one function to check all three passwords.

Or call one function to check all three passwords.

Yes, I want to do this. May you help?