Can you tell what your Current Level is just by reading all the DIO?
Potentiometer would be better for position feed then the limit switch as it will give you continuous read on your position
No loops in Teleop
Read Distance “calculate” DesiredLevel
Read the DIOs “calculate” CurrentLevel
If CurrentLevel = DesiredLevel then write 0 out to Lift Motor
If CurrentLevel > DesiredLevel then write -20 out to Lift Motor
If CurrentLevel < DesiredLevel then write +20 out to Lift Motor
NO LOOP
The Teleop loop will loop around and you get to do it all over again.
As long as CurrentLevel < DesiredLevel the motor goes up
As long as CurrentLevel > DesiredLevel the motor goes down
Each time through Teleop you check CurrentLevel and compare it to DesiredLevel.
You can put this all in a case structure and enable or disable with the toggle I sent you earlier.
Again from my question asked early, Can you always tell your Current Level by the limit switches alone?
Or do you have positions in between
If you can not always tell your position then you will have to maintain the level in some kind of state machine.