Code will load and run once but not again

I decided to change out the sensor. The code works with an external power supply (batteries).