LCD Printing Garbage

Hello… For some reason with this code (and this code only) my LCD prints garbage. It appears the garbage on the display updates on correct time intervals but the screen always picks garbage. I can provide a pin digarm but I am pretty sure these are all connect correctly.

If I load a example code onto my board using "LiquidCrystal lcd(1,2,4,5,6,7); " as how the board is connected the display is correct.

Any help would be great! I’ve been staring at this far to long now. I’m assuming it has to do with my set up because it prints garbage from the very start.

Note: I was not able to upload all my subroutines. If needed I can provide but these put my post out of range of the allowed characters.

#include <Wire.h>
#include <LiquidCrystal.h> 
#include "BlueDot_BME280.h"
#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
#include <Keypad.h>

LiquidCrystal lcd(1,2,4,5,6,7); 

bool temp_message = false; 
bool before_logic_message = false;    
bool after_hb_check_message = false;
bool heart_beat_message = false;   
bool door_flag = false;
bool keyPadCheck_flag = false;
bool load_value_flag = false;
bool correct_value_flag = false;
bool pw_flag = false; 
bool keyPad_Flag1 = false; 
bool keypad_Flag2 = false;
bool math_flag = false; 
bool temp_flag = false; //*************************************************ONCE FINISHING PROGRAM RESET TO FALSE! SET TO TRUE WHILE WRITING KEY PAD CODE************************* 
bool flag_Entry = true; 
bool flag_heartbeat =false;

//Key pad variable
int logic_sum = 0;
int fails = 0; 
int math_tries = 0;
int key; 
int value; 
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};
 
int padCount = 0; 

int j = 2;
int i = 0;
byte rowPins[ROWS] = {24, 23, 22, 19}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {27, 26, 25}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

char* secretCode = "1234";
int position = 0;

//TEMP and Humidity variable 
BlueDot_BME280 bme1;                                     //Object for Sensor 1
BlueDot_BME280 bme2;                                     //Object for Sensor 2

int bme1Detected = 0;                                    //Checks if Sensor 1 is available
int bme2Detected = 0;                                    //Checks if Sensor 2 is available

float temp_read1 = 0;
float temp_read2 = 0; 


//heartbeat variables 
const int PulseWire = 0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
PulseSensorPlayground pulseSensor; //Creates a pulseSensor object. 

void setup() 
{ 
  pulseSensor.analogInput(PulseWire);   
  pulseSensor.setThreshold(Threshold); 
  pinMode(14, LOW); //Reading int from Pulse sense on Uno.   
  setup_hum();
  //if (pulseSensor.begin())
  //Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.  
}


void loop() {
 // Serial.println("PUtting something on the screen"); 
  key = keypad.getKey();
  
  if(flag_Entry == true)
  {
      
      if(bme1Detected && temp_flag == false)
      {
        lcd.print("Lets take your temp"); 
        temp_check(); 
        lcd.clear(); 
      }

      if(temp_flag == true && temp_message == false)
      {
         lcd.clear();
         lcd.print("Congratz!!!");
         delay(500);
         lcd.clear();
         lcd.print("You may not be infected");
         delay(500);
         lcd.clear();
         lcd.print("But lets make sure"); 
         delay(500);
         lcd.clear();
         lcd.print("Lets check...");
         delay(200);
         lcd.setCursor(2,2); 
         lcd.print("your heart rate");  
         temp_message = true; 
      }

          if(temp_flag == true && flag_heartbeat == false) 
      { 
         int uno_read_dig = digitalRead(14); 
         if(uno_read_dig == HIGH)
            flag_heartbeat = true;
         else
            flag_heartbeat = false;
      }

      if(flag_heartbeat == true && after_hb_check_message == false)
      {
        lcd.setCursor(1,0);
        lcd.clear();
        lcd.print("Awesome!");
        lcd.setCursor(1,1);
        lcd.print("You're not dead"); 
        delay(1000);
        lcd.clear();
        lcd.setCursor(16,2); 
        lcd.print("But can you do"); 
        delay(500);
        lcd.print(".");
        delay(500);
        lcd.print(".");
        delay(500);
        lcd.print(".");
        delay(500);
        lcd.print(".");
        delay(500);
        lcd.clear(); 
        lcd.print("LOGIC!!!");
        delay(1000);
        lcd.clear();
        lcd.print("Please push *"); 
        delay(500); 
        after_hb_check_message = true;
      }
      
      if(flag_heartbeat == true && after_hb_check_message == true) 
      { 
        if(keyPadCheck_flag == false)
        {
           keyPadCheck(); 
        }
      }
      
      if(flag_heartbeat == true && after_hb_check_message == true && keyPadCheck_flag == true && before_logic_message == false)
      {
         lcd.clear(); 
         lcd.print("please do a..."); 
         lcd.setCursor(1,1); 
         lcd.print("litte math!");
         before_logic_message = true;   
      }

      if(keyPad_Flag1 == true && before_logic_message == true)
      {
         if(load_value_flag == false)
         {
         math_input(); //Loads two varibles and outputs values on to 
         key = 0;
         }
      }
      if(load_value_flag == true && key !=0) 
      { 
          if(math_tries < 2)
          {
             logic_check();
          }
       
          else
          {
             load_value_flag = false;
             math_tries = 0;
             fails ++; 
          }
      }
       if(pw_flag == true && key != '*')
       {
            position = 0;
            setLocked(true);
       }  
       if(key == secretCode[position])
       {
            position++; 
       } 
       else if(key != secretCode[position] && key != 0 && key != '*')
       { 
            position = 0;
            fails ++; 
       }
       if(position == 4)
       {
            setLocked(false); 
       }
       if(door_flag == true)
       {
          //call subroutine for unlocking door. 
          //Serial.print("The door is unlocked");
       }
      
  }
  if(fails == 2)
  {
      //trigger defense.   
  }
}

Never mind! I figured it out!

Bhysjulien: Never mind! I figured it out!

Would be nice if you shared the solution as future reference for others ;)

It's perfectly obvious!

LiquidCrystal lcd(1,2,4,5,6,7);

Paul__B: It's perfectly obvious!

LiquidCrystal lcd(1,2,4,5,6,7);

Perfectly obvious question from my side ;) Why ?

There is no Serial so it should work? Or not?