The way you made it now makes the code blocking. It keeps waiting until you entered the whole password.
Also, it’s not the whole code! You should post at least complable code.
And I see a lot of variables that aren’t declared inside the function so must be global. But I see no need for pass3 (which is a terrible terrible variable name) and others to be global.
And the function is called checkpassword (checkPassword would be preferred) but it does more then that. I would split it between a enter password, a check password function and a update password function. NOTE, I made a blocking version as well because you didn’t post all the code. Also, how do you recall the checkpassword() function now?
static byte attempts = 0;
Serial.println("Entered pass key is correct");
attempts = 0;
Serial.println("Wrong Password, Try again");
if(attempts >= MaxAttempts)
//Do something about it!
//call2(); //to where?
void inputPassword(char password)
int d = 0;
//int e; //not used
Serial.println(" Enter your PassKey: ");
char key = kpd.getKey(); //no need for global
if(key != NO_KEY)
password[d] = key;
}} //See the double bracket? That means you f*ck up the indentation ;)
bool checkPassword(char password)
for(byte i = 0; i < PasswordLength; i++) //think a for look is more clear
//char test3 = pass3[y]; no need for this
//char test4 = pass2[y];
if(password[i] != setPassword[i])
//y++; don by the for-loop
return true; //if non triggered a return befor the password is correct