My 16*2 LCD display works erratically. Please advise.

my 16*2 LCD display work sometimes and most of the time does not.
this is the code I use with LiquidCrystal library.

#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  lcd.setCursor(0,1);
  lcd.print("This is a test");
}

I connected rs to 12
en to 11
D4 to 5
D5 to 4
D6 to 3
D7 to 5
sometimes this code works otherwise either the screen is blank or the top row darkens when i crank up
the darkness.
Any ideas how to remedy this?

See what happens when you display your message in setup() and leave loop() blank between the brackets.

Don

Could be bad or loose wiring, or bad solder connections to the LCD module.
Can you post a photo of your setup?

--- bill

Try to power arduino via extrenal power not USB. Or USB via AC plug same with you charge mobile phone

tried all 3.doesnt work. still thanks for the advice. sorry i took so long to reply. hate that lcd screen >:( >:( >:( >:( >:(