Button state not detected within loop

This sketch is based on Ali Hamza electronic lock project.
I’ve modified/added to it to match my needs. Up to this point all my mods have worked fine.

This project is for my RV to lock/unlock the side door “basically for my kids” with out keys.
It would certainly be cheaper/easier to buy an electronic lock, however I plan to add more functions “like auto slide movement” or “Auto leveling” and I love projects.
I’m using the 2560 mega3, powered by 12VDC/ 4 marine battery’s/ trickle Solar charged for the coach.

My last addition to the sketch is push buttons for the inside of the door to lock and unlock the door. The manual deadbolt knob is covered by 3D printed knob cover and servo driven.

“Pic’s and code below”

My problem/question is, I add a simplistic code for button state change to eventually drive the servo
but I can’t get a simple “serial.println” response.

I’m placing a jumper from GND to pin 43 and leaving it to drive the pin low, Which should give me a constant message between timer counts. Pin 43 is the only button I’m working with at the moment to get this working. Diving the pin LOW gives no message.

The line I’m referring to is the first line in the “void loop”
I’ve tried adding an additional line of code and LED to see the change by LED but no change there either.
Because I’m still a novice I thought perhaps it was the location of my line of code within the void loop and moved it to the last curly bracket "within the void loop, but still no response.

I used the same line of code “by it’s self” on another mega2560 and it works fine as far as detecting the button change.
Instead of speculating anymore, I figured I would come to the experts.
Thanks for advice in advance.

////////////////////////////includes////////////////////////////
#include <Servo.h>                         // To move the deadbolt 
#include <Keypad.h>                        // input key strokes
#include<LiquidCrystal.h>                  // view key strokes
#include<EEPROM.h>                         // for Password save
LiquidCrystal lcd(22, 24, 26, 28, 30, 32); // rs-en-D7-D6-D5-D4
////////////////////////eeprom password store////////////////////
char password[4];
char pass[4], pass1[4];
int i = 0;
//////////////////////servo//////////////////////////////////////
Servo myservo;
//////////////////////keypad/////////////////////////////////////
char customKey = 0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
////////////////////////////////Buzzer///////////////////////////
int buzzer = 10;
///////////////////////////////timer/////////////////////////////
int timer = 0;
//////////////////////////////LCD BACKLIGHT/////////////////////
int light = 48;
/////////////////////////////inside RV lock/unlock//////////////
int btnlock = 43;
int btnunlock = 45;



void setup()
{
  Serial.begin(9600);
  digitalWrite (light, HIGH);
  pinMode (light, OUTPUT);
  pinMode (btnlock, INPUT_PULLUP);
  pinMode (btnunlock, INPUT);
  lcd.begin(16, 2);
  pinMode(buzzer, OUTPUT);
  lcd.print(" Electronic ");
  Serial.print(" Electronic ");
  lcd.setCursor(0, 1);
  lcd.print(" Lock ");
  Serial.print(" Lock ");
  delay(2000);
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  for (int j = 0; j < 4; j++)
    EEPROM.write(j, j + 49);
  for (int j = 0; j < 4; j++)
    pass[j] = EEPROM.read(j);
  myservo.attach(12);
  myservo.write (150);
  delay (1000);
  myservo.detach ();
}

void loop()
{
int buttonState = digitalRead(btnlock);
if (buttonState, LOW){
  Serial.println ("button_change");
}
  while (timer < 1000)                   //Added for LCD display backlight sleep
  {
    timer = timer + 1;
    Serial.print("timer = ");
    Serial.println(timer);
    if (customKey)                       //If key press, timer resets
      timer = 0;
    if (timer >= 1000) {                 //Otherwise 1000 = display blackout
      changemsg ();
      delay (2000);
      digitalWrite (light, LOW);
      delay (50);
      timer = 0;
    }
    if (customKey) {                    //Key press required for light on
      digitalWrite (light, HIGH);
    }                                   //These lines goto "void locked"
    if (customKey == '#') {             // locks door with out defauting to "bad password" to lock up.
      locked ();
    }
    customKey = customKeypad.getKey();  //begins code for password accept and or change.
    if (customKey == '*')
      change();

    if (customKey)
    {
      password[i++] = customKey;
      lcd.print(customKey);
      Serial.print(customKey);
      beep();
    }
    if (i == 4)
    {
      delay(200);
      for (int j = 0; j < 4; j++)
        pass[j] = EEPROM.read(j);
      if (!(strncmp(password, pass, 4)))
      {
        beep();
        lcd.clear();
        lcd.print("Passkey Accepted");
        Serial.println("Passkey Accepted");
        myservo.attach (12);
        myservo.write (150);
        delay(2000);
        myservo.detach ();
        lcd.clear();
        lcd.print("Door Unlocked");
        Serial.println("Door Unlocked");
        delay (1000);
        lcd.clear();
        lcd.print("Enter Passkey");
        Serial.println("Enter Passkey");
        lcd.setCursor(0, 1);
        i = 0;
      }
      else
      {
        myservo.attach (12);
        myservo.write (15);
        digitalWrite(buzzer, HIGH);
        lcd.clear();
        lcd.print("Access Denied...");
        Serial.println("Access Denied...");
        delay(2000);
        myservo.detach ();
        lcd.clear();
        lcd.print("Enter Passkey:");
        Serial.println("Enter Passkey:");
        lcd.setCursor(0, 1);
        i = 0;
        digitalWrite(buzzer, LOW);
      }
    }
  }
}
void change()
{
  int j = 0;
  lcd.clear();
  lcd.print("Current Passkey");
  Serial.println("Current Passkey");
  lcd.setCursor(0, 1);
  while (j < 4)
  {
    char key = customKeypad.getKey();
    if (key)
    {
      pass1[j++] = key;
      lcd.print(key);
      Serial.print(key);
      beep();
    }
    key = 0;
  }
  delay(500);

  if ((strncmp(pass1, pass, 4)))
  {
    lcd.clear();
    lcd.print("Wrong Passkey...");
    Serial.println("Wrong Passkey...");
    lcd.setCursor(0, 1);
    lcd.print("TRY Again");
    Serial.println("TRY Again");
    delay(1000);
  }
  else
  {
    j = 0;
    lcd.clear();
    lcd.print("New Passkey:");
    Serial.println("New Passkey:");
    lcd.setCursor(0, 1);
    while (j < 4)
    {
      char key = customKeypad.getKey();
      if (key)
      {
        pass[j] = key;
        lcd.print(key);
        Serial.print(key);
        EEPROM.write(j, key);
        j++;
        beep();
      }
    }
    lcd.print(" Done......");
    Serial.println(" Done......");
    delay(1000);
  }
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  customKey = 0;
}
void beep()
{
  digitalWrite(buzzer, HIGH);
  delay(20);
  digitalWrite(buzzer, LOW);
}
void locked ()                             //lock from out side with one key press "#"
{
  lcd.clear();
  lcd.write ("Door Locked");
  myservo.attach (12);
  myservo.write (15);
  delay (2000);
  myservo.detach ();
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  i = 0;
}
void changemsg ()
{
  lcd.setCursor(0, 1);
  lcd.print("* to Change Pass");
  Serial.println("* to Change Pass");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 1);
  lcd.print("# to lock Door");
  Serial.println("# to lock Door");
  delay(2000);
  lcd.clear();
  lcd.print("Enter Passkey:");
  Serial.println("Enter Passkey:");
  lcd.setCursor(0, 1);
  i = 0;
}

 if (buttonState, LOW)

Should be

 if (buttonState == LOW)

Thank you UKHeliBob
You were correct "goofy mistake"!

It didn't fix the state change detect problem, but I never would have figured it out with out changing that.
I just found out what the problem is after "changing that error" but still don't completely understand the reasoning. I need to read more!
The line is out side of the "while loop" and moving it to the end also put it out side of the while loop.
Once I put it in the loop it started working.

I need to read up more on the structure of loops and how the code works/doesn't work in each.

Thanks again!

Re posting final code encase a novice “like me” might want it.

////////////////////////////includes////////////////////////////
#include <Servo.h>                         // To move the deadbolt 
#include <Keypad.h>                        // input key strokes
#include<LiquidCrystal.h>                  // view key strokes
#include<EEPROM.h>                         // for Password save
LiquidCrystal lcd(22, 24, 26, 28, 30, 32); // rs-en-D7-D6-D5-D4
////////////////////////eeprom password store////////////////////
char password[4];
char pass[4], pass1[4];
int i = 0;
//////////////////////servo//////////////////////////////////////
Servo myservo;
//////////////////////keypad/////////////////////////////////////
char customKey = 0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
////////////////////////////////Buzzer///////////////////////////
int buzzer = 10;
///////////////////////////////timer/////////////////////////////
int timer = 0;
//////////////////////////////LCD BACKLIGHT/////////////////////
int light = 48;
/////////////////////////////inside RV lock/unlock//////////////
int btnlock = 43;
int btnunlock = 45;



void setup()
{
  Serial.begin(9600);
  digitalWrite (light, HIGH);
  pinMode (light, OUTPUT);
  pinMode (btnlock, INPUT_PULLUP);
  pinMode (btnunlock, INPUT_PULLUP);
  lcd.begin(16, 2);
  pinMode(buzzer, OUTPUT);
  lcd.print(" Electronic ");
  Serial.print(" Electronic ");
  lcd.setCursor(0, 1);
  lcd.print(" Lock ");
  Serial.print(" Lock ");
  delay(2000);
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  for (int j = 0; j < 4; j++)
    EEPROM.write(j, j + 49);
  for (int j = 0; j < 4; j++)
    pass[j] = EEPROM.read(j);
  myservo.attach(12);
  myservo.write (150);
  delay (1000);
  myservo.detach ();
}

void loop()
{
  while (timer < 1000)                   //Added for LCD display backlight sleep
  {
    timer = timer + 1;
    Serial.print("timer = ");
    Serial.println(timer);
    if (customKey)                       //If key press, timer resets
      timer = 0;
    if (timer >= 1000) {                 //Otherwise 1000 = display blackout
      changemsg ();
      delay (2000);
      digitalWrite (light, LOW);
      delay (50);
      timer = 0;
    }
    if (customKey) {                    //Key press required for light on
      digitalWrite (light, HIGH);
    }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
int buttonState1 = digitalRead(btnlock);
if (buttonState1 == LOW)
{
  myservo.attach (12);
  myservo.write (15);
  delay (2000);
  myservo.detach ();
}
int buttonState2 = digitalRead(btnunlock);
if (buttonState2 == LOW)
{
  myservo.attach (12);
  myservo.write (150);
  delay (2000);
  myservo.detach ();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
                                         //These lines goto "void locked"
    if (customKey == '#') {             // locks door with out defauting to "bad password" to lock up.
      locked ();
    }
    customKey = customKeypad.getKey();  //begins code for password accept and or change.
    if (customKey == '*')
      change();

    if (customKey)
    {
      password[i++] = customKey;
      lcd.print(customKey);
      Serial.print(customKey);
      beep();
    }
    if (i == 4)
    {
      delay(200);
      for (int j = 0; j < 4; j++)
        pass[j] = EEPROM.read(j);
      if (!(strncmp(password, pass, 4)))
      {
        beep();
        lcd.clear();
        lcd.print("Passkey Accepted");
        Serial.println("Passkey Accepted");
        myservo.attach (12);
        myservo.write (150);
        delay(2000);
        myservo.detach ();
        lcd.clear();
        lcd.print("Door Unlocked");
        Serial.println("Door Unlocked");
        delay (1000);
        lcd.clear();
        lcd.print("Enter Passkey");
        Serial.println("Enter Passkey");
        lcd.setCursor(0, 1);
        i = 0;
      }
      else
      {
        myservo.attach (12);
        myservo.write (15);
        digitalWrite(buzzer, HIGH);
        lcd.clear();
        lcd.print("Access Denied...");
        Serial.println("Access Denied...");
        delay(2000);
        myservo.detach ();
        lcd.clear();
        lcd.print("Enter Passkey:");
        Serial.println("Enter Passkey:");
        lcd.setCursor(0, 1);
        i = 0;
        digitalWrite(buzzer, LOW);
      }
    }
  }
}
void change()
{
  int j = 0;
  lcd.clear();
  lcd.print("Current Passkey");
  Serial.println("Current Passkey");
  lcd.setCursor(0, 1);
  while (j < 4)
  {
    char key = customKeypad.getKey();
    if (key)
    {
      pass1[j++] = key;
      lcd.print(key);
      Serial.print(key);
      beep();
    }
    key = 0;
  }
  delay(500);

  if ((strncmp(pass1, pass, 4)))
  {
    lcd.clear();
    lcd.print("Wrong Passkey...");
    Serial.println("Wrong Passkey...");
    lcd.setCursor(0, 1);
    lcd.print("TRY Again");
    Serial.println("TRY Again");
    delay(1000);
  }
  else
  {
    j = 0;
    lcd.clear();
    lcd.print("New Passkey:");
    Serial.println("New Passkey:");
    lcd.setCursor(0, 1);
    while (j < 4)
    {
      char key = customKeypad.getKey();
      if (key)
      {
        pass[j] = key;
        lcd.print(key);
        Serial.print(key);
        EEPROM.write(j, key);
        j++;
        beep();
      }
    }
    lcd.print(" Done......");
    Serial.println(" Done......");
    delay(1000);
  }
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  customKey = 0;
}
void beep()
{
  digitalWrite(buzzer, HIGH);
  delay(20);
  digitalWrite(buzzer, LOW);
}
void locked ()                             //lock from out side with one key press "#"
{
  lcd.clear();
  lcd.write ("Door Locked");
  myservo.attach (12);
  myservo.write (15);
  delay (2000);
  myservo.detach ();
  lcd.clear();
  lcd.print("Enter Passkey");
  Serial.println("Enter Passkey");
  lcd.setCursor(0, 1);
  i = 0;
}
void changemsg ()
{
  lcd.setCursor(0, 1);
  lcd.print("* to Change Pass");
  Serial.println("* to Change Pass");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 1);
  lcd.print("# to lock Door");
  Serial.println("# to lock Door");
  delay(2000);
  lcd.clear();
  lcd.print("Enter Passkey:");
  Serial.println("Enter Passkey:");
  lcd.setCursor(0, 1);
  i = 0;
}