VARIABLES ISSUE from library password / EEPROM

Hi,
I have no programming experience and I have serious issues with what variabelen to use to get a result.

Intention is

  1. to read the first five positions of the EEPROM (a 1 byte incheck code and a 4 digit number)
  2. to get an 4 position input from the keyboard that is follow by pressing “A”
  3. compare the input password to the EEPROM password (what type of variables do I use here???)

I tried several ways to het a result but no good result.
Some help would be highly appreciated.

#include <Password.h>
#include <Keypad.h>
#include <EEPROM.h>
Password password = Password( “0000” );
const byte ROWS = 4; const byte COLS = 4;
char keys[ROWS][COLS] = {{‘1’,‘2’,‘3’,‘A’},{‘4’,‘5’,‘6’,‘B’},{‘7’,‘8’,‘9’,‘C’},{’*’,‘0’,’#’,‘D’}};
byte rowPins[ROWS] = { 2,3,4,5 }; byte colPins[COLS] = { 6,7,8,9, };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

byte pincheck;
char pincode[5];

void setup(){
Serial.begin(9600);
//read EEPROM position 0 and position 1 TO 4
pincheck = EEPROM.read(0);

for (int x=1; x<4; x++){
y=x-1;
pincode[y] = EEPROM.read(x);
Serial.print(pincode[y]);
Serial.print(" “);
Serial.print(EEPROM.read(x));
Serial.print(” x = “); Serial.print(x);Serial.print(” y = ");Serial.println(y);}
pincode[4]= “/0”;

keypad.addEventListener(keypadEvent); //generate event checker
}

void loop(){keypad.getKey();}

void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:

switch (eKey){
case ‘A’: checkPasswordA(); password.reset(); break;

default: password.append(eKey);}}}

void checkPasswordA(){
if (password.evaluate()){

???
}

Welcome to the Forum. Please read Nick Gammon’s two posts at the top of this Forum for guidelines on posting here, especially on using code tags for posting your source code. It helps us read your code if you format it before posting in the IDE using Ctrl-T.

As a starting point, try the following code, and then modify it for your keypad.

#include <EEPROM.h>

#define PWLENGTH 4


char pincode[PWLENGTH + 1];
char password[PWLENGTH + 1];

void setup() {
  char init[] = "Jack";
  Serial.begin(9600);

  initPW(init, sizeof(init));          // Write a test PW to EEPROM
  readPW(password, sizeof(pincode));   // Read test PW
  Serial.println("Enter password: ");  // Prompt user
}

void loop()
{
  int index = 0;

  if (Serial.available() > 0) {
    index = Serial.readBytesUntil('\n', pincode, PWLENGTH);
    pincode[PWLENGTH] = '\0';
  }
  if (index) {
    Serial.print("Password entered: ");
    Serial.println(pincode);
    if (memcmp(password, pincode, PWLENGTH) == 0) {
      Serial.println("Passwords match");
    } else {
      Serial.println("You have 30 seconds to leave the building safely");
    }
    index = 0;
  }
}

void initPW(char *temp, int len)
{
  int i;
  for (i = 0; i < len; i++)    // Write test PW
    EEPROM.write(i, temp[i]);
}

void readPW(char *pw, int len)
{
  int i;

  for (int i = 0; i < len; i++) {  // Read PW from EEPROM
    pw[i] = EEPROM.read(i);
  }
  pw[PWLENGTH] = '\0';
}

Thanks for your help, I'll check it out and keep you posted !

for (int x=1; x<4; x++){
  y=x-1;
  pincode[y] = EEPROM.read(x);

Why do you make things so difficult for yourself?

void loop(){keypad.getKey();}

Read which key, if any, is being pressed. Throw the result away. Why bother?