Mental block with programming sequence

Hello everyone,

I'm stuck here for quite abit, Please take a look at my code and assist me with some inputs!!

I'm doing a keypad that takes in your hp number and stores in an array for the gsm which in turn sends a password to you.

By keying in the randomly assigned password, d10 would send a high signal to trigger my relay.
So far I have done up to this point.

#include <SCoop.h>              //multi tasking functions
#include <Wire.h>               // low level i2c functions
#include <a_delays.h>           // for debouncing
#include <a_i2c.h>              // high level i2c functions
#include <a_lcd.h>              // lcd uses i2c
#include <a_key.h>              // keypad uses i2c
#include <SoftwareSerial.h>
#define IGT 8                  // ignition pin

SoftwareSerial mySerial(5, 6);  // RX, TX

void password (void);
void getNumber (void);
void gsm (void);

extern char hpbuf[9];
extern int pswbuf[8];
extern int genbuf[8];

void setup()
{
    i2cInit();                 // called first before keyInitI2c()
    keyInitI2c(0x3a);          // provide i2c address
    lcdInitI2c(0x39);          // provide i2c address
    Serial.begin(57600);       //Baud rate of arduino
    
    pinMode(IGT,OUTPUT);
    digitalWrite(IGT,HIGH);    //High-Low-High ignition for gsm
    delay(100);
    digitalWrite(IGT,LOW);
    delay(150);
    digitalWrite(IGT,HIGH);
    delay(100);
  
    Serial.begin(57600);
    Serial.println("Enter Handphone number");

    Serial.print("HpNumber");
    
}

void loop() {
    uint8_t c, a, i;
    lcdClrScr();                          //remove previous message on lcd screen
    lcdPutStr("Pls enter HP No.");
    lcdSetXY(0,1);                        //bring down hp. number on next line
    getNumber(hpbuf);                     //display keypad input
    lcdSetXY(0,0);
    lcdPutStr("Press D to send");
     a = myKeyGet();
     //d = keyChk();
     
    switch(a){
   
    case 'D':
        lcdClrScr();
        lcdPutStr("Pls Check your  phone.");
        Serial.println(hpbuf);
        gsm();
        
        lcdClrScr();
        lcdPutStr("Please Enter PSW.");
        delay(5000);
        lcdSetXY(0,1);
        
        a = myKeyGet();
       // while(1){
        //if (password() == ){
          
        //pinMode(10,OUTPUT);
       //digitalWrite(10,HIGH);  
       // }
        
    break;
      
      case 'C':
        lcdClrScr();
        lcdPutStr("Pls enter HP No.");
        hpbuf=0;                        //reset array to 0
     break;
      
     case 'A':
        lcdClrScr();
        lcdSetXY(0,0);
        lcdPutStr("C to clr screen and D for psw.");
        delay(5000);
       
      break;
      
      case 'B':
        lcdClrScr();
        lcdSetXY(0,0);
        lcdPutStr("C to clr screen and D for psw.");
        delay(5000);
       
      break;
       }
}



Next Tab
char hpbuf[9];                 //set array to having 8 + 1 digit
char HPNumber[9] = "12345678";


void getNumber(char buf[]){
    uint8_t i,a;
    Serial.println("Getting Hp Number");
    
      for(i=0; i<=7; i++){    //allows only 8 Digit for Hp Number
      
      a = getDigit();
      
      lcdPutCh(a);            // Display Hp Number on lcd
      buf=a;               // store hp number into array for gsm
    
        }
      
    buf=0;                 // reset my input hp number
}
     
uint8_t myKeyGet(void){
        uint8_t a;
        while(1){
          if((a = keyChk())!= NOKEY_CODE){
        
            return a;
          }
          yield();
        }
      }
      
      
uint8_t getDigit(void){
        
         while(1){  uint8_t c;
         c = myKeyGet();
              
              if ( c >= '0' && c <= '9'){
       
              return c;
               }
          }
}





Next Tab
  void chkPsw(char pswbuf[]){
    uint8_t i,a;
    Serial.println("Getting password");
    
      for(i=0; i<=7; i++){    //allows only 8 Digit for Password
      
      a = getDigit();
      
      lcdPutCh(a);            // Display password on lcd
      pswbuf=a;               // store password into array for checking
    
        }
      
    pswbuf=0;                 // reset my input password
}
     
uint8_t myPswGet(void){
        uint8_t a;
        while(1){
          if((a = keyChk())!= NOKEY_CODE){
        
            return a;
          }
          yield();
        }
      }
      
      
uint8_t getNum(void){
        
         while(1){  uint8_t c;
         c = myPswGet();
              
              if ( c >= '0' && c <= '9'){
       
              return c;
               }
          }
}

As you all can see, after sending a password to the user phone, It returns straight to the entering HP number.
I require the next step of entering the received password to trigger my relay if it is correct.

Thanks for taking your time in the wall of code.
Appreciate all replies.

Moderator edit: Wall of code tags tidied-up.

You need to post your code inside [ code ] [ /code ] tags to stop the forum software from mangling your code. You can fix this by editing your post, selecting (highlighting) the code and clicking on the # button in the edit window. AT the moment, your code to get user input is garbled.

I assume you want to keep prompting for an HP until you get a valid input.
I assume you only support one password being enabled at a time, and the current password is disabled when the users enters any password value.
I assume that after entering a password (right or wrong) the system goes back to prompting for the next HP.

If those assumptions are all valid then the blocking approach you're taking will work. In that case, you need function which receives a password from the user, and a function which compares the user-supplied password against the current password to test whether the value is correct. Then call these two functions between lines 66 - 72 in your code. If the password is correct, carry out the associated action. Finally, clear the current HP and current password.

Im really glad that you guys have shown patience to a newbie like me.

i have since deleted the thread at programming questions after being pointed out.

And yes, Peter you were spot on. I initially started of with arrays for storage but too many conflicts start to get at me.

I would give your suggestion a shot right now.

Many Thanks1

As I progressed on, I created an array to store randomSeed from my analog pin which are used as passwords.

randNumber = random(10);
a = randNumber;
numbuf[i]=a;

Under my checkPassword function, This is something I have,

if (pswbuf ==numbuf[9]){
pinmode(10, output);
digitalwrite(10,high);
lcdPutStr("Unlocked");
}

I have problems compiling due to the error message pointing to (ISO C++ forbids comparison between pointer and integer)

Can someone show me what's a proper way of linking them up for comparing?

Thanks

Here is an example that you can try.

struct {
  char *password[10];
  char *user[10];
} check;

int cnt = -1, i = 0;

void setup()
{
  Serial.begin(9600);

  Add("1234", "Andy");
  Add("5678", "Joe");
  Add("abcd", "mike");

 while(i != cnt + 1)
 {
  if(!strcmp( "5678", check.password[i]) )  // this compares all the added passwords to one specific one.
  {   
    Serial.println("is good");
    Serial.print("Welcome back, ");
    Serial.print(check.user[i]);
    Serial.println();
    break;
  }
  else i++;
 }
 if(i == cnt + 1) Serial.println("Not Good");
}

void loop() 
{
  
}

void Add(char * input,  char * username) {
  cnt++;
  check.password[cnt] = input;
  check.user[cnt] = username;
}

Currently comparing my arrays with each other, I realized that they may be checking every digit individually.

For eg. Password is 08947654

On Lcd Screen it will be :
Please Enter Password.
0n8orrect9asswo4d
unlocked

Here are my 2 functions. 1 storing a random seed number into array and the other comparing the user input key.

char numbuf[9];

void password(char buf[])
{
    uint8_t i,a;
    randomSeed(analogRead(0));
    int randNumber;
  
  for(int i=0; i < 8; i++)
    {
    randNumber = random(10);    // Print random numbers with no seed value
    a = randNumber;
      
       numbuf[i]=a; 
    mySerial.print(randNumber);
    }

}

// if analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.

Next is my check Password function

char pswbuf[9];                 //set array to having 8 + 1 digit
char pswNumber[9] = "98765432";
  
  void chkPsw(char pswbuf[]){
    uint8_t i,a;
    Serial.println("Getting password");
    
      for(i=0; i<=7; i++){    //allows only 8 Digit for Password
      
      a = getNum();
      lcdSetXY(0,1);
      lcdPutCh(a);            // Display password on lcd
      pswbuf[i]=a;               // store password into array for checking
      
      if(pswbuf[9] == numbuf[9]){
        Serial.println("Password Correct");
          pinMode(10,OUTPUT);
         digitalWrite(10,HIGH); 
        lcdPutStr("Unlocked"); 
      }
        
       else{
         
         
         lcdPutStr("Incorrect Password");
    
        }
      
      
    pswbuf[i]=0;                 // reset my input password
}
  }
     
uint8_t mykeyGet(void){
        uint8_t a;
        while(1){
          if((a = keyChk())!= NOKEY_CODE){
        
            return a;
          }
          yield();
        }
      }
      
      
uint8_t getNum(void){
        
         while(1){  uint8_t c;
         c = myKeyGet();
              
              if ( c >= '0' && c <= '9'){
       
              return c;
               }
          }
}

Post your full code, and for comparing the password use strcmp() or strncmp().

Alright! Here my my full codes. I have split them up into 5 tabs for easy reading.

#include <SCoop.h>              //multi tasking functions
#include <Wire.h>               // low level i2c functions
#include <a_delays.h>           // for debouncing
#include <a_i2c.h>              // high level i2c functions
#include <a_lcd.h>              // lcd uses i2c
#include <a_key.h>              // keypad uses i2c
#include <SoftwareSerial.h>
#define IGT 8                  // ignition pin

SoftwareSerial mySerial(5, 6);  // RX, TX

void password (void);
void getNumber (void);
void gsm (void);
void chkPsw (void);

extern char hpbuf[9];
extern char pswbuf[9];
extern char genbuf[9];
extern char numbuf[9];

void setup()
{
    i2cInit();                 // called first before keyInitI2c()
    keyInitI2c(0x3a);	       // provide i2c address
    lcdInitI2c(0x39);          // provide i2c address
    Serial.begin(57600);       //Baud rate of arduino
    
    pinMode(IGT,OUTPUT);
    digitalWrite(IGT,HIGH);    //High-Low-High ignition for gsm
    delay(100);
    digitalWrite(IGT,LOW);
    delay(150);
    digitalWrite(IGT,HIGH);
    delay(100);
  
    Serial.begin(57600);
    Serial.println("Enter Handphone number");

    Serial.print("HpNumber");
    
}

void loop() {
    uint8_t c, a, i;
    lcdClrScr();                          //remove previous message on lcd screen
    lcdPutStr("Pls enter HP No.");
    lcdSetXY(0,1);                        //bring down hp. number on next line
    getNumber(hpbuf);                     //display keypad input
    lcdSetXY(0,0);
    lcdPutStr("Press D to send");
     a = myKeyGet();

     
    switch(a){
   
    case 'D':
        lcdClrScr();
        lcdPutStr("Pls Check your  phone.");
        Serial.println(hpbuf);
        gsm();
        
        lcdClrScr();
        lcdPutStr("Please Enter PSW.");
        chkPsw(pswbuf);
      
        
    break;
      
      case 'C':
        lcdClrScr();
        lcdPutStr("Pls enter HP No.");
        hpbuf[i]=0;                        //reset array to 0
     break;
      
     case 'A':
        lcdClrScr();
        lcdSetXY(0,0);
        lcdPutStr("C to clr screen and D for psw.");
        delay(5000);
       
      break;
      
      case 'B':
        lcdClrScr();
        lcdSetXY(0,0);
        lcdPutStr("C to clr screen and D for psw.");
        delay(5000);
       
      break;
       }
}
char hpbuf[9];                 //set array to having 8 + 1 digit
char HPNumber[9] = "97589398";


void getNumber(char buf[]){
    uint8_t i,a;
    Serial.println("Getting Hp Number");
    
      for(i=0; i<=7; i++){    //allows only 8 Digit for Hp Number
      
      a = getDigit();
      
      lcdPutCh(a);            // Display Hp Number on lcd
      buf[i]=a;               // store hp number into array for gsm
    
        }
      
    buf[i]=0;                 // reset my input hp number
}
     
uint8_t myKeyGet(void){
        uint8_t a;
        while(1){
          if((a = keyChk())!= NOKEY_CODE){
        
            return a;
          }
          yield();
        }
      }
      
      
uint8_t getDigit(void){
        
         while(1){  uint8_t c;
         c = myKeyGet();
              
              if ( c >= '0' && c <= '9'){
       
              return c;
               }
          }
}
char numbuf[9];

void password(char buf[])
{
    uint8_t i,a;
    randomSeed(analogRead(0));
    int randNumber;
  
  for(int i=0; i < 8; i++)
    {
    randNumber = random(10);    // Print random numbers with no seed value
    a = randNumber;
      
       numbuf[i]=a; 
    mySerial.print(randNumber);
    }

}

// if analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.
char pswbuf[9];                 //set array to having 8 + 1 digit
char pswNumber[9] = "98765432";
  
  void chkPsw(char pswbuf[]){
    uint8_t i,a;
    Serial.println("Getting password");
    
      for(i=0; i<=7; i++){    //allows only 8 Digit for Password
      
      a = getNum();
      lcdSetXY(0,1);
      lcdPutCh(a);            // Display password on lcd
      pswbuf[i]=a;               // store password into array for checking
      
      if(pswbuf[9] == numbuf[9]){
        Serial.println("Password Correct");
          pinMode(10,OUTPUT);
         digitalWrite(10,HIGH); 
        lcdPutStr("Unlocked"); 
      }
        
       else{
         
         
         lcdPutStr("Incorrect Password");
    
        }
      
      
    pswbuf[i]=0;                 // reset my input password
}
  }
     
uint8_t mykeyGet(void){
        uint8_t a;
        while(1){
          if((a = keyChk())!= NOKEY_CODE){
        
            return a;
          }
          yield();
        }
      }
      
      
uint8_t getNum(void){
        
         while(1){  uint8_t c;
         c = myKeyGet();
              
              if ( c >= '0' && c <= '9'){
       
              return c;
               }
          }
}
void gsm(){
  
    
  mySerial.begin(9600);          //Baud rate of the GSM/GPRS Module
  
  mySerial.println("AT");        //AT command
  delay(500);    
  
  mySerial.println("AT+CMGF=1"); //SMS mode   
  delay(500);
  
  mySerial.print("AT+CMGS=");    // To allow input of HP No.
  
  mySerial.println(hpbuf);       //retrieve HP No. from GetNum()
  delay(500);
  
  mySerial.println("Hi, Your Password is:");
  password(numbuf);                    // call password function to generate random psw
  mySerial.println();            //send password
  mySerial.write(0x1A);          // 0x1A = crtl-z (ascii) end of message
  delay(5000);
 
  
  
  delay(50);
}
      //reference from http://www.induino.com/2013_11_01_archive.html

And hazardsMind could you kindly show me how to make use of strcmp().

Thanks

CTRL + T, will do wonders for your code, give it a try.

Ok, strcmp().
Well your master password is "97589398", so what you do is enter a password with the keypad and using strcmp or strncmp you can see if they are a match.

strcmp:

A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2;
And a value less than zero indicates the opposite.

if( !strcmp( numbuf, "97589398") )  // This will only be true if the passwords are equal
{
   Serial.println("Password Correct");
   pinMode(10,OUTPUT); // this is usually declared in the setup function
   digitalWrite(10,HIGH); 
   lcdPutStr("Unlocked"); 
}   
else lcdPutStr("Incorrect Password");  // if it's just one line, it doesn't need breackets

Now you can also use strncmp, but this function is more of a filter.

char str[][5] = { "R2D2" , "C3PO" , "R2A6" };
int n;
puts ("Looking for R2 astromech droids...");
for (n=0 ; n<3 ; n++)
if (strncmp (str[n],"R2xx",2) == 0) // the 2 tells the function to look for a possible match 2 chars inward
{
printf ("found %s\n",str[n]);
}
return 0;

OUTPUT:
Looking for R2 astromech droids...
found R2D2
found R2A6

Thanks so much for the prompt reply, HazardsMind.

At my level I'm having great difficulty comprehending strncmp

I'm trying out this code and it gives my the same result as the initial program:

if( !strcmp( numbuf, "97589398") )  // This will only be true if the passwords are equal
{
   Serial.println("Password Correct");
   pinMode(10,OUTPUT); // this is usually declared in the setup function
   digitalWrite(10,HIGH); 
   lcdPutStr("Unlocked"); 
}   
else lcdPutStr("Incorrect Password");  // if it's just one line, it doesn't need breackets

What I have on the user interface(LCD Screen) is:

Please Enter Password.

The moment I key In 9, this exact thing is shown(9incorrect Password)
At the Next number, 7,(7incorrect Password)

This keeps repeating for 8 times, with the numbers changing at the front.
On the last digit 8, It changes to correct and D10 led indicator lights up.

How do I make it show on lcd:

Please Enter Password.
97589398(from mykeyget input)

After comparing, Followed by:
Password Correct.

Btw CTRL + T was astonishing. Auto formating makes it so much easier.

Thank you.

The moment I key In 9, this exact thing is shown(9incorrect Password)
At the Next number, 7,(7incorrect Password)

That's because you need to collect the full password first then compare it. Right now your reading in one char, then comparing it, second char, comparing it...etc. Use a while loop to gather the full password first then see if it is a match.

HazardsMind:
That's because you need to collect the full password first then compare it. Right now your reading in one char, then comparing it, second char, comparing it...etc. Use a while loop to gather the full password first then see if it is a match.

I have been trying since just now,this may sound silly but how do you actually insert the while loop in to gather all?

This is not tested but if it doesn't work with 9 being in the while loop, change it to 8.

void getNumber(char buf[]){
    uint8_t i = 0, a;
    Serial.println("Getting Hp Number");
    
    while(i != 9 )   //allows only 8 Digit for Hp Number
    { 
       a = getDigit(); 
       lcdPutCh(a);            // Display Hp Number on lcd
       buf[i]=a;               // store hp number into array for gsm       
       i++;
    }   
    //buf[i]=0;                 // reset my input hp number
}

Thanks for following me closely.

I have managed to get the passwords line out nicely.But I'm not sure if they are in the format for comparing.

When I do a Serial.println(numbuf); I cant get a line showing my password as 12345678 in serial monitor.

What can be done?

I have called 2 different arrays for comparision.

Array 1: random seed generated from program

char numbuf[9];

void password(char buf[])
{
  uint8_t i,a;
  randomSeed(analogRead(0));
  int randNumber;

  for(int i=0; i < 8; i++)
  {
    randNumber = random(10);    // Print random numbers with no seed value
    a = randNumber;

    buf[i]=a; 
    mySerial.print(randNumber);
    Serial.println(randNumber);
    }
}

Array 2: To be input by user in to Keypad.

char pswbuf[9];                 //set array to having 8 + 1 digit
char pswNumber[9] = "11111111";

void storePsw(char buf[]){
  uint8_t i,a;
  Serial.println("Getting Password from Keypad");

  for(i=0; i<=7; i++){    //allows only 8 Digit for password

      a = GetNum();

    lcdPutCh(a);            // Display password on lcd
    buf[i]=a;               // store password into array for gsm

  }

  buf[i]=0;                 // reset my input password array
}

uint8_t myKeyPad(void){
  uint8_t a;
  while(1){
    if((a = keyChk())!= NOKEY_CODE){

      return a;
    }
    yield();
  }
}


uint8_t GetNum(void){

  while(1){  
    uint8_t c;
    c = myKeyPad();

    if ( c >= '0' && c <= '9'){

      return c;
    }
  }
}

My function to compare them

void unlock(char buf[])
{

  uint8_t i,a;
  Serial.println("comparing");

     if( !strcmp( numbuf, pswbuf) )  // This will only be true if the passwords are equal
     {
      Serial.println("Psw Correct");
      pinMode(10,OUTPUT); // this is usually declared in the setup function
      digitalWrite(10,HIGH); 


      lcdSetXY(0,0); 
      lcdPutStr(" Unlocked");
      Serial.println(" Unlocked");
      delay(10000);
    }
  
    
  else{

    lcdSetXY(0,0);
    lcdPutStr("Psword Incorrect");
    delay(3000);  
    Serial.println("Password Incorrect");



  }


  pswbuf[i]=0;                 // reset my input password
}

So wait, it works but you can't see your password? Where did you put the Serial.println(numbuf) ? Do you want to see the full password or as you input it?

I cant get it to work. Leaving me clueless as the programming seems in place.

The situation right now is I'm getting an incorrect password prompt all the time.

Monitoring its chain of instruction was the next best I could do.

Thus, trying to serialprint the numbuf to start troubleshooting.

However I would have to find out what stops me from viewing this function in serial monitor as well.

Can anyone shed some light on this?

Try this,

/* 
 || @version 1.0
 || @author Andrew Mascolo
 ||
 || @description
 || Simple use of keypad, password and LCD
 */
#include <Keypad.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

#define Password_Lenght 7 // Give enough room for six chars + NULL char

LiquidCrystal_I2C lcd(0x20,20,4);
char Data[Password_Lenght]; // 20 is the number of chars it can hold
char Master[Password_Lenght] = "123456"; 
byte data_count = 0, master_count = 0;
boolean good;
char customKey;

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

byte rowPins[ROWS] = {
  2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  10,9,8}; //connect to the column pinouts of the keypad

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); //initialize an instance of class NewKeypad 

void setup(){
  lcd.init();// initialize the lcd 
  lcd.backlight();
}

void loop()
{
  lcd.setCursor(0,0);
  lcd.print("Enter Password");
  customKey = customKeypad.getKey();
  if (customKey)
  {
    Data[data_count] = customKey; // 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
  }

  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)) 
      good = true;
    else 
      good = false;  

    lcd.setCursor(0,0);
    delay(1000); // added 1 second delay to make the 
    if(good) 
    {
      lcd.clear();
      lcd.print("Password is good");
      delay(1000);
      lcd.clear();
      clearData(); 
    }
    else 
    {
      lcd.clear();
      lcd.print("Password is bad");
      delay(1000);
      lcd.clear();
      clearData();
    }
  }
}

void clearData()
{
  while(data_count !=0)
  {   // This can be used for any array size, 
    Data[data_count--] = 0; //clear for new data
  }
  return;
}

If you want to identify multiple passwords, use this. I have also made a library that does exactly this found HERE

/* 
 || @version 1.0
 || @author Andrew Mascolo
 ||
 || @description
 || Simple use of keypad, multiple passwords and LCD
 */
#include <Keypad.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20,20,4);
char Data[20]; // 20 is the number of chars it can hold
const int Usercount = 3;
char Master[2][7] = {
  "123456",
  "000123"
};

char * User[Usercount] = {
  "Master","Andrew","INVALID"};
  
int currentCommand = 0;
int MasterCount = 6;
int good_Count = 0;
int user = 0;
boolean good,goodUser;
char customKey;

const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10,9,8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); 

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
}

void loop()
{
  lcd.setCursor(0,0);
  lcd.print("Enter Password");
  customKey = customKeypad.getKey();
  if (customKey)
  {
    Data[currentCommand] = customKey;
    lcd.setCursor(currentCommand,1);
    lcd.print(Data[currentCommand]);
    currentCommand++;
  }

  if(currentCommand == MasterCount)
  {
    delay(1000);
    while(user != 2)
    {
      for(int count = 0; count < MasterCount; count++)
      {
        if(Data[count] == Master[user][count])
        {
          good_Count++;
        }  
      }
      if(good_Count == MasterCount)
      {
        good_Count = 0;
        good = true; 
        break;
      }
      else
      { 
        good_Count = 0; 
        user++; 
        good = false;
      }
    }
    
    lcd.setCursor(0,0);
    if(good)
    {
      lcd.clear();
      lcd.print("Password is good");
      lcd.setCursor(0,1);
      lcd.print(User[user]);
      delay(2000);
      user = 0;
      lcd.clear();
      clearData(); 
    }
    else 
    {
      lcd.clear();
      lcd.print("Password is bad");
      lcd.setCursor(0,1);
      lcd.print(User[user]);
      delay(2000);
      user = 0;
      lcd.clear();
      clearData();
    }
  }
  if(customKey == '*')
  {
    lcd.clear();
    clearData();
    while(goodUser != true)
    {
      lcd.setCursor(0,0);
      lcd.print("Change Password");
      lcd.setCursor(0,1);
      lcd.print("Enter User: ");
      user = customKeypad.getKey();
      if(user)
      {
        user -= '0'; // convert from char to int
        lcd.print(user);
        if(user < Usercount) 
        { // if within number of users
          delay(1000);
          goodUser = true; //gets out of while loop
          user -= 1; // ENTER: 1 = master, 2 = user, but the array is 0 for master and 1 for user. This makes it so.
          lcd.clear();
        }
        else 
        {
          delay(1000);
          lcd.clear();
          lcd.print("Invalid User");
          delay(2000);
          lcd.clear(); 
        }
      } 
    }
    goodUser = false;// stays in while loop
    while(customKey != '#')
    {
      lcd.setCursor(0,0);
      lcd.print(User[user]); // prints out the user
      lcd.setCursor(0,1);
      lcd.print("Press # to confirm");
      customKey = customKeypad.getKey();
      if (customKey)
      {
        Master[user][currentCommand] = customKey;
        lcd.setCursor(currentCommand,2);
        lcd.print(Master[user][currentCommand]);
        MasterCount = currentCommand;
        currentCommand++;
      }
    }
    if(customKey == '#') // press # to store new passwrd for user
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(User[user]);
      lcd.print(" is reset");
      delay(1000);
      clearData();
      lcd.clear();
    }
  }
}

void clearData() 
{
  user=0;
  while(currentCommand !=0)
  {   // This can be used for any array size, 
    Data[currentCommand--] = 0; //clear for new data
  }
  return;
}

I have finally got it solved. This is due to calling different integers and char, comparing them does not give a correct output.

Thus it isn't displayed.

You can check the solutions here.
http://forum.arduino.cc/index.php?topic=222934.msg1619289#msg1619289

Another help needed here!!

Having run the whole program, I have a knock sensor function which arms my system.
I'm unable to program it such that it waits all the time for a shock while polling the system on what it should do.

Something like multi-tasking.

Can yield() be used? Or rather, appropriate?

Thanks.