I am trying to move my TrayMotor to a certain point according to my pot values, my solution in driver control doesn’t seem to work in the autonomous period. I tried plugging this function in autonomous and it did not stop the tray motor once it reached its position. Any help? Language: Python
if TrayPot.value(RotationUnits.DEG) < 135:
TrayMotor.spin(DirectionType.FWD,25,VelocityUnits.PCT)
else:
TrayMotor.stop(BrakeType.HOLD)
Do you have that statement wrapped in a loop? If you don’t it will be evaluated once and then the program will move on, probably never stopping the lift.
In autonomous you don’t generally have while loops. In order for this to update motor power it must be checked regularly. If you are doing something else simultaneously consider multithreading