How do i stop the password from "sliding"
if the password is 123456 and i enter 1234567 the password is still valid?
void checkPIN()
{
int correct=0;
for (int q=0; q<6; q++)
{
if (attempt[q]==PIN[q])
{
correct++;
}
}
if (correct==6)
{
systemSet();
//correctPIN();
}
else
{
//incorrectPIN();
systemUnSet();
}
for (int zz=0; zz<16; zz++) // wipe attempt
{
attempt[zz]=0;
}
}
//------------------------------------------------------------------------------------
void readKeypad()
{
char key = keypad.getKey();
if (key != NO_KEY) // only be bothered to do something if a key was pressed
{
fromKeypad++; //Each time there is a character received, increment the counter:
lcd.setCursor(fromKeypad-1, 1);
lcd.print(key);
switch(key)// look for the special keys to initiate an event
{
case '*':
z=0;
fromKeypad = 0;
break;
case '#':
delay(100); // for extra debounce
fromKeypad = 0;
lcd.clear();
checkPIN();
break;
default:
attempt[z]=key;
z++;
KeyPadTone();// play a beep to acknowledge that key pressed
}
}
}