Password Library and Creating a Variable Integer

I messed around with brackets and where I put password.append, but nothing worked.

You should show your attempt(s). That way we can point out what you did wrong. Anyway ...

I came up with below which fixes the issues in code. Try to understand it and ask if you don't.

Add the below somewhere before setup(). This will replace your three booleans, so get rid of them.

// the modes that your application can be in
enum MODES
{
  MAINMENUMODE,
  SECURITYMODE,
  COOPMODE
};

// the current mode; initialise with MAINMENUMODE
MODES mode = MAINMENUMODE;

The enum (short for enumerator) defines the available modes; every 'name' actually reflects a number so the mode variable can have the values 0..2 but it is irrelevant as we will only use the names.

The compiler will throw a warning if you try to assign a number to the mode variable as shown below; you should not ignore that warning.

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_170104\sketch_apr27a.ino:24:14: warning: invalid conversion from 'int' to 'MODES' [-fpermissive]

 MODES mode = 55;

The compiler will also throw a warning on

Password password = Password( "1234" );

as shown below

C:\Users\WIMSTU~1\AppData\Local\Temp\arduino_modified_sketch_562853\sketch_apr27a.ino:26:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Password password = Password( "1234" );

This one is quite harmless but if you want to get rid of it, you either 'hack' the library (the better way) or you modify the line to below.

Password password = Password( (char *)"1234" );

Next you can modify loop() to do what you want it to do

void loop()
{
  char myKey = myKeypad.getKey();

  if (myKey == '#')
  {
    mode = SECURITYMODE;
    SecurityScreen();
  }

  if (mode == SECURITYMODE && myKey == '*')
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Invalid Key  ");
    delay (2000);
    SecurityScreen();
  }
  else if (mode == MAINMENUMODE && myKey == '*')
  {
    MainMenu(); //Replace with coop Door function down the line
  }

  if (mode == SECURITYMODE)
  {
    if (myKey >= '0' && myKey <= '9')
    {
      lcd.setCursor(pressCnt, 1);
      lcd.print('*');
      password.append(myKey);
      pressCnt++;
    }
    if (pressCnt == 4) {
      checkPassword();
      pressCnt = 0;
    }
  }
}

Code is tested with simulation of the keypad using the serial port.

This leaves a few things to be desired. If you are in security mode and press '#' (e.g. 123#), what needs to happen? For you to implement :wink:

Next I suggest that you write a few functions to handle the different modes and the associated key presses.

/*
  handle access control
  In:
    key (from keypad)
*/
void accessControl(char key)
{
}

/*
  handle coop mode
  In:
    key (from keypad)
*/
void coopControl(char key)
{
}

/*
  handle main menu mode
  In:
    key (from keypad)
*/
void mainMenu(char key)
{
}

Those functions will handle the key presses, switch mode if needed etc
And in loop() you call them when needed

void loop()
{
  char myKey = myKeypad.getKey();

  switch (mode)
  {
    case MAINMENUMODE:
      mainMenu(myKey);
      break;
    case SECURITYMODE:
      accessControl(myKey);
      break;
    case COOPMODE:
      coopControl(myKey);
      break;
  }

}

I will help you later with that. But you can see how clean loop() stays.

Note:
did not look at Bulldog's code