Door lock code - looking for improvements

I am a kinda new to arduino this is my second project, I got a code from the forum and made some heavy modification, it's working but I am not sure if I did everything ok, if someone with free time could take a look and help with some improvements, thanks in advance.

This code is for a keypad with LCD that uses two passwords to open two doors.

//Code by Reyfus
//Original Code by: ironicDeveloper 12/18/2011
//Help & parts of code from arduino forum

#include <Keypad.h> //Includes keypad library
#include <LiquidCrystal.h> //Includes LCD Library

LiquidCrystal lcd(12, 11, 17, 16, 15, 14); //Set LCD Pins

const byte ROWS = 4; //Set Leypad Pins
const byte COLS = 3; 
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; 
byte colPins[COLS] = {8, 7, 6}; 

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //Creates the keypad

char inputArray[4]; //Creates the input array
char Main[4] = {'4','6','2','7'}; //creates arra for correct password first door 
char Guest[4] = {'1','2','3','4'}; //creates arra for correct Password Second door

#define registerPin 10 //First door open pin
#define secondPin 9 //Second door open pin

int i = 0; //variable to count number of key pressed
long tempo = 0; //variable that counts inactive time for display reset  

void setup()
{
lcd.begin(16, 2); //start the lcd
pinMode(registerPin, OUTPUT); //set First door open pin
pinMode(secondPin, OUTPUT); //set Second door open pin
lcd.print("Enter password"); //Print Message
lcd.setCursor(0, 1); //put cursor on second line
}

void loop()
  {
 
  char key = kpd.getKey(); //read ley press

  
    if(key)
{


inputArray[i] = key; //record key press in input array
tempo=0; // zero inactive time variable
i++; // increase key pressed variable
lcd.print(key); //print key pressed to LCD


if (i == 4) //If 4 keys have been pressed
 {
 
if (inputArray[0] == Main[0] &&  //compare input password to door 1 password
inputArray[1] == Main[1] && //compare input password to door 1 password
inputArray[2] == Main[2] && //compare input password to door 1 password
inputArray[3] == Main[3]) //compare input password to door 1 password
  {
   digitalWrite(registerPin, HIGH); //Activate door 1 relay
   delay(500); // wait half a second
   digitalWrite(registerPin, LOW); //deactivate relay
   lcd.clear(); //clears lcd
   lcd.print("Correct Password"); // write message
   delay(1500); // Wat 1.5 sec
   memset(inputArray,'\0',4); //clears the input array
   lcd.clear(); //clear lcd
   lcd.print("Enter password"); //write message
   lcd.setCursor(0, 1); //put cursor on second line
     }
  else  
  {
    if (inputArray[0] == Guest[0] &&  //compare input password to door 2 password
inputArray[1] == Guest[1] && //compare input password to door 2 password
inputArray[2] == Guest[2] && //compare input password to door 2 password
inputArray[3] == Guest[3]) //compare input password to door 2 password
  {
   digitalWrite(secondPin, HIGH); //Activate door 2 relay
   delay(500); // wait half a second
   digitalWrite(secondPin, LOW); //deactivate relay
   lcd.clear(); //clears lcd
   lcd.print("Correct Password"); // write message
   delay(1500); // Wat 1.5 sec
   memset(inputArray,'\0',4); //clears the input array
   lcd.clear(); //clear lcd
   lcd.print("Enter password"); //write message
   lcd.setCursor(0, 1); //put cursor on second line
     }
  else  // in case of wrong password
  {
   memset(inputArray,'\0',4); //clears the input array
  delay(1000); //wait 1 sec
  lcd.clear(); //clear lcd
  lcd.print("Wrong Password"); // write message
  delay(1500); // Wat 1.5 sec
  lcd.clear(); //clear lcd
  lcd.print("Enter password"); //write message
  lcd.setCursor(0, 1); //put cursor on second line
  }
        }
   
   i=0; //Zero number of keys pressed
 
}
    }
   
   tempo++; //increase inactive time varieable
   if (tempo > 4500000) //if inactive time variable reaches near 45sec
   {
  i=0; //zero key presses
  memset(inputArray,'\0',4); //clears the input array
  lcd.clear(); //clear lcd
  lcd.print("Enter password:"); //write message
  lcd.setCursor(0, 1); //put cursor on second line
  tempo=0; // zero inactive time variable
  }
};

I would get rid of the memset() calls. They can be very dangerous if you get any of the arguments wrong and in your case they aren't needed. When you set 'i' (you should pick a better name for that) to zero you won't look at the contents of inputArray until all four elements have been replaced with user input. The zeroes you are placing in inputArray are never used.

Otherwise the coding looks quite good to me.

Because you use:

          lcd.clear(); //clear lcd
          lcd.print("Enter password"); //write message
          lcd.setCursor(0, 1); //put cursor on second line

in four different places you might want to make it into a function:

void LCDReset() {
  lcd.clear(); //clear lcd
  lcd.print("Enter password"); //write message
  lcd.setCursor(0, 1); //put cursor on second line
}

That way if you want to change the design of the initial display you only have to change it in one place.

Similarly, the code:

          lcd.clear(); //clear lcd
          lcd.print(message); // write message
          delay(1500); // Wat 1.5 sec

could be turned into a function that takes a message as an argument.

and help with some improvements, thanks in advance.

I started to
read your code
but I seem to
be having some
difficulties. Your code
jumps all over
the page.

Clearly, you didn't bother using Tools + Auto Format before posting the code. Yet you want us to go cross-eyed trying to follow it. I'll pass.

This could be improved:

if (i == 4) //If 4 keys have been pressed
 {
 
if (inputArray[0] == Main[0] &&  //compare input password to door 1 password
inputArray[1] == Main[1] && //compare input password to door 1 password
inputArray[2] == Main[2] && //compare input password to door 1 password
inputArray[3] == Main[3]) //compare input password to door 1 password

The explicit 4 could be replaced with a constant and also used to declare your arrays. Handy when you decide that four character passwords are too short. To that end also, the four characters being checked one by one in the 2nd if statement is a little clumsy and is another place you would have to make changes if the size is increased. Use memcmp instead and similarly where you check the guest password.