Problem with ADC and USART output

I am using a Freeduino board(equivalent to Arduino Duemilanove with atmega328).

I am using a simple program. The program checks for the channel 0 input of ADC and stores value in a variable. The value of the variable is output to pin 9(PWM pin). An LED is connected to this pin and so its brightness is varied by this simple program. The ADC value is being monitored using serial monitor. I am using this code:

void setup()
  Serial.println("Starting program: ");
void loop()
{  int val;
    {  delay(500);
        Serial.print("ADC reading = ");

The problem is that whatever be the input voltage of potentiometer connected to ADC channel 0, in the Serial monitor, it always shows ADC reading = 1023 But the brightness of the LED varies whenever I turn the pot. So it is not as if ADC is reading 1023 always. The program is working fine, only the serial monitor output is stuck at 1023.

And if nothing is connected to channel 0 of ADC, the noise values are read as usual. They vary quite a lot.

Where is the problem? Why is the serial monitor stuck at 1023?

Why do you need the while statement in your loop? Try removing the while statement, and let the loop function make your code repeat. while(1) freezes your loop, and causes the contents of while(1) to repeat forever. Perhaps this will not allow the serial data to change.