Have you tried replacing
int sensorValue = analogRead(A0);
with
int sensorValue = analogRead(0);
I don't have a Mega to hand to test what A0 compiles to (its definitely done different in Arduino 1.0 from earlier Arduino softwares - I can't find the definitions in 1.0). Perhaps its broken for Megas? Sounds a bit unlikely though.