LCD shows only black rectangular boxes in second line

i have used LCD 16x 2 jhd 162a, and whichever code i try running it shows same display, with second line filled with rectangular boxes and first line is clear.
In other forums i read, that this is common problem and it is problem of initialization. the code sent by the arduino is too fast, so i placed some delay in the code but the display remain the same. I have attched 10k port at contrast pin and had also play 10k resistor at Vee pin to control the brightness but the display remains the same. Can anyone help with this ?
Here is the code and i have attached the pictures too.
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of columns and rows:
delay(1000);
lcd.begin(16, 2);
// Print a message to the LCD.

lcd.print("hello");
}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}

Hinata:
i have used LCD 16x 2 jhd 162a, and whichever code i try running it shows same display, with second line filled with rectangular boxes and first line is clear.

That's the typical state after a power-on of the LCD.
Power ==>OK
Data ==> not available

As the LiquidCrystal library provided with the Arduino IDE is tested by millions of Arduino users, most likely your cabling is wrong.

Schematics?

Or maybe wrong voltage, if you try to use a 5V LCD with a 3.3V Arduino board.

Double check your data lines. Are you using the I2c shield on the LCD or ??? If using the I2c, make sure the SDA and SCL are connected to SDA and SCL on both boards(lcd and arduino) respectively. Do not cross them like a typical serial comm connection.

Bill

I have connected 11th pin of LCD to digital pin 5
12th pin of LCD to digital pin 4
13th pin of LCD to digital pin 3
14th pin of LCD to digital pin 2
and i am using arduino uno

even if I change the digital pins to 7, 8 , 9 , 10, the output remains same.

Billdefish:
Double check your data lines. Are you using the I2c shield on the LCD or ??? If using the I2c, make sure the SDA and SCL are connected to SDA and SCL on both boards(lcd and arduino) respectively. Do not cross them like a typical serial comm connection.

I don't think that his LCD is a I2C one as he is using this line with Arduinos LiquidCrystal library to initialize it:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

The cabling between Arduino and LCD is shown in that picture:

could it be because of a bad management of the cursor's position ?

jasmino:
could it be because of a bad management of the cursor's position ?

Good point.

Ive been spoiled by my I2c modules so I dont have any experience with direct connecting but I will try try to help. as suggested, you should use the setCursor and print commands hand in hand with eachother.

int a = A0;

void setup()
{
lcd.begin(16,2)
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hello world");
}

void loop()
{
}

Each time you change the screens output, you should use lcd.clear so as not to overlap prints and display unreadable or distorted text.

Bill

If you back off the contrast what happens?
I had a similar problem, BAD LCD :confused: