LCD contrast not working and not displaying text

Hello;

I am new to the arduino. I was making a portable weather station with and arduino NANO, DHT 11 temp and humidity sensor, and a 16 X 2 LCD. after i made the circuit I plugged it into the computer and everything was working as I intended it to but after I plugged it in the second time the LCD contrast stopped working and it stopped displaying text.

At first I thought I might have made a wrong connection; so I made another circuit with the UNO, LCD, and a 10K potentiometer; the problem was still there.
I tried it over again with two more 16 X 2 LCD's but the problem still continued.

I tried it with the I2C module and the contrast started working with the in built potentiometer. Then i thought the problem was with the arduino software so i deleted it and reinstalled it but the problem still continued. I tried with two arduino UNO's and one arduino NANO but nothing seems to be solving the problem.

does anyone know the solution??

thank you.

 #include <LiquidCrystal.h>

int rs = 7;
int en = 8;
int d4 = 9;
int d5 = 10;
int d6 = 11;
int d7 = 12;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int dt = 1000;


void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  

}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.setCursor(0, 0);
  lcd.print("Hello World");
  lcd.setCursor(0, 1);
  lcd.print("I am Alive");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Watch me count");
  for (int j = 0; j <= 10; j+=1){
    lcd.setCursor(0, 1);
    lcd.print(j);
    delay(1000);
     
  }
  lcd.clear();


}