Velocity Control Help

I’m trying to get a loop where if I press a button on the joystick, it starts a velocity control loop.

You mean something like this?

While(true)
{
 if ( VexRT [Btn8U] == 1 )
 {
  StartTask ( velocityControl );
 }
wait1Msec(20);
}

This would make it so that while your while loop is running if you press upper 8 button on the primary controller than the task, VelocityControl, will be started. However, instead of VelocityControl you would put the name of your velocity control task inside those brackets. I hope this helps.

Yeah, I figured it out xD

I would toggle a global variable (we’ll call is apply_velocity_control) used in the task rather than starting the task again.

Let the task start in user control and then have the while loop have an if statement inside looking for apply_velocity_control == true

the button triggers the value of this. The button up is generally better than the button press. Toggle the state of the boolean every time you detect button up. The task will pick that up and start its velocity control. Next button press will stop the velocity control.

See code in here to get the button ups and toggling states. Yours is simpler as it can be a binary on/off
https://vexforum.com/t/help-with-3-position-toggle/32846/1