Could someone go over the code and see what the problem is, it just skips over the get key and always returns no key
//ENTER PASSWORD ON KEYPAD
void enterCode()
{
lcd.setCursor(0,0);
lcd.println("Enter password:");
lcd.setCursor(0 ,1);
lcd.print(" ");
enteredKey = keypad.getKey();
if (enteredKey != NO_KEY) // makes sure a key is actually pressed, equal to (customKey != NO_KEY)
{
Data[data_count] = enteredKey; // store char into data array
lcd.setCursor(data_count, 1); // move cursor to show each new char
lcd.print(Data[data_count]); // print char at said cursor
data_count++; // increment data array by 1 to store new char, also keep track of the number of chars entered
}
else
{enterCode();}
if (data_count == Password_Lenght - 1) // if the array index is equal to the number of expected chars, compare data to master
{
if (!strcmp(Data, Master)) // equal to (strcmp(Data, Master) == 0)
{
lcd.clear();
correctPassword();
}
}
}
You are calling the enterKey() function from inside the enterKey() function. Unless yoy really, really know what you are doing then such recursion is a very bad idea
enterCode() is a function, enteredKey is a variable. There is no enteredKey function. I recall the enteredCode() in the else to bring it back to the start of the function so that when no key is pressed it try's again to get a key. So if I spam the key pad occasionally the number appears but it isn't sustainable.
Now we are both wrong, so let's correct my mistake with the function name. You are calling the enterCode() function from inside the enterCode() function