code backwards and soldered circuit no longer works

It looks to me like you're defining the startup state of the sensor gate in your code and not getting it from the sensor.

So the state of the sensor at startup will define whether it measures blocked or unblocked.

You should get the initial state from the sensor at startup and/or confirm it in the interrupt routine.

As for the random values on your soldered circuit. Does it need a pulldown on the sensor pin? Exactly what you need to do would probably depend on the sensor.