Hi, Can I suggest you analogRead the sensor at the start of the loop rather than somewhere in the middle.
Thanks.. Tom..