Sounds like it is resetting, likely due to a power issue. I had similar issues when running servos and Arduino from same battery pack.
If it were me I would disconnect the LCD and sensor, download the Blink program, connect your 9V power and see if it blinks.