ARDUINO MULTIPLE PASSWORD

#include <Password.h> //http://www.arduino.cc/playground/uploads/Code/Password.zip
#include <Keypad.h> //http://www.arduino.cc/playground/uploads/Code/Keypad.zip

Password password1 = Password( “1234” );
Password password2 = Password( “1889” );

const byte ROWS = 4; // 4 rows
const byte COLS = 3; // 3 columns
// Define the Keymap
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 );
void setup(){

Serial.begin(9600);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}

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

//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print("Pressed: ");
Serial.println(eKey);
switch (eKey){
case ‘*’: checkPassword();

break;

case ‘#’: password1.reset();
password2.reset();
break;
default: password1.append(eKey);
password2.append(eKey);
}
}
}

void checkPassword(){
if (password1.evaluate()){
Serial.println(“code 1 success”);

}
else if (password2.evaluate()){

Serial.println(“code 2 success”);

}else {
Serial.println(“Wrong”);
//add code to run if it did not work
}
}

}

Nice code. Should be in code tags though. Was there a question to go with this?

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

There's not much use in calling getKey if you're just throwing away the value it returns.

I need help with above code please.
The problem is when i enter the second password it says Wrong
i believe password2 is not being evaluated
plz help me fix it
thankyou

Are you entering the first password, seeing success, and then trying the second? What happens if you try the second one first?

the first one works fine no matter when i try at first or after entering the second one.
The second doesnt work any time entering at first or after entering the first one.

Are the Serial prints showing the right digits? Maybe add a print to the beginning of checkPassword to print out both passwords and make sure they have in them what you expect.

I am checking entered digits on the serial monitor.
It's shows that m entering the correct digits.
I think something is wrong with the program it is not checking the second password
It only checking the first password
When I enter the second password it's says wrong

Delta_G:
Maybe add a print to the beginning of checkPassword to print out both passwords and make sure they have in them what you expect.

@bcashjung

Did you get this problem fixed?

mgargiulo:
@bcashjung

Did you get this problem fixed?

Do you really think that person is hanging around for a year reading responses?