You set your sensorPin as an OUTPUT (while it should be an INPUT).
Then when enabled it's written HIGH, disabled it's written LOW.
After that you try to read from that pin regardless of whether you have it enabled - so naturally when enabled it now returns 1023, when disabled it returns 0 or values very close to that.
Set it to INPUT, then don't try to write to it but instead take your readings based on whether it's enabled or not.