3*4 keypad

Could somebody help me out here. Trying to make a pasword entry with a 3*4 keypad. Can someone tell me why when I input 1234 “WELCOME” isnt printed? As you can see 1234 is the password.

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
int count = 0;
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
 {'1','2','3','A'},
 {'4','5','6','B'},
 {'7','8','9','C'},
 {'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

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

char pass[5] = "1234"; //clave de la wea
char typed[5];
void setup(){
 Serial.begin(9600);
}
 
void loop(){
 char key = customKeypad.getKey();

 if (key){
   Serial.println(key);
   typed[count] = key;
   count = count+1;
 }
 
 Serial.println(typed);
 Serial.println(pass);
 if (count==4){
   Serial.println("hi");
   if (typed==pass){
     Serial.println("WELCOME");
   }
 }
 delay(100);
}

That’s a 4X4 keypad.

Look up strcmp().

http://www.cplusplus.com/reference/cstring/strcmp/

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
int count = 0;
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

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

const char pass[5] = "1234"; //clave de la wea
char typed[5];

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

void loop()
{
  char key = customKeypad.getKey();

  if (key)
  {
    typed[count] = key;
    count++;
    Serial.println(typed);

    if (count > 3)
    {
      Serial.println("hi, ");

      if (strcmp(typed, pass) == 0)
      {
        Serial.println("WELCOME rtallar");
      }
      
      else
      {
        Serial.println("Wrong password!");
      }
      count = 0;
    }
  }

  delay(100);

} //END of loop()

larryd has pointed you at strcmp() for comparing two null terminated character arrays (c-strings).

For strcmp to work properly, both pass and typed need to be null terminated character arrays.

This is achieved by the syntax of the declaration of a char array within quotation marks “” which adds a null terminator. Each character array is 5 chars, made up of 4 digits and the null terminator.

char pass[5] = "1234"; //clave de la wea
//char typed[5];
char typed[5] = "";