error msg - uploading problem

Hello,

I am getting this error msg when uploading: avrdude: ser_drain(): read error: Device not configured

I am trying to read values from a photoresistor:

Green goes to A0
Red goes to 5V
Black goes to GND

and the code for it:

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(10);
}

I am using a leonardo, is there something I am missing?
I can press reset and then upload and it's uploading fine, but when I touch the photoresistor, there is no value output.
any ideas?

are you waiting for the serial begin?

required for the leonardo...

 void setup() { 
 //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

try that first.

that doesn't work. I can only upload when I press the reset button first on the board