incorrect numeric output to lcd panel

I have one of the standard LCD shields. It is mounted on a UNO clone.

The following code outputs the correct value to the Terminal but I get a random and fixed number coming on the LCD. It is puzzling. Has anybody any idea why?

#include <LiquidCrystal.h>

/*******************************************************

This program outputs to lcd and to serial the A1 value

********************************************************/

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
lcd.begin(16, 2); // start the library
//lcd.setCursor(0,0);
//lcd.print("this is the first"); // print a simple message
//lcd.setCursor(0,1);
//lcd.print("this is the second"); // print a simple message
Serial.begin(9600);
}

void loop()
{
// read the input on analog pin A1:
int sensorValue = analogRead(1);
Serial.println(sensorValue);
lcd.setCursor(0,0);
lcd.print(sensorValue);
delay(250); // delay in between reads for stability
}

Since it is a shield and assuming that there is nothing mechanically wrong with it, then
the culprit is most likely that the constructor you are using LiquidCrystal lcd(8, 9, 4, 5, 6, 7); is wrong.
Or maybe you can't use the LiquidCrystal library with your shield.

Who knows?

You have the shield, we don't.

Thanks ieee488.

I have found my stupid mistake. It was not to clear the lcd display in between writes. On analysing the numbers written to the terminal I noticed that the lcd display was retaining all but the first digit when I earthed the ADC.

Maybe somebody else can learn from this that writing to the the lcd is not the same as writing to a terminal. You need to clear the digits in between writes to the lcd by

lcd.clear()