how do you go from autonomous to joystick in a competition?
Once you plug the competition switch into your controller, the operator of the match has control of your robot, they can start the autonomous as soon as the match starts and you can’t control your robot until the autonomous period ends, the operator will then start driver control after the 15 second autonomous period is up and you have 1:45 to score as much as possible. so it’s basically the game operator that switches the autonomous to driver control
Make sure to include
#pragma platform(VEX2)
#pragma competitionControl(Competition)
#include "Vex_Competition_Includes.c"
at the beginning of your file. This allows the robot to be controlled by the field controller. So, instead of putting your code in the main task — task main() — put it in one of these three functions:
//This code will run once the robot turns on, is connected to the joystick, and is enabled.
void pre_auton()
{
}
//Put your autonomous code here.
task autonomous()
{
}
//Put your driver control code here
task usercontrol()
{
//Use a while(true) loop to run code forever (until the end of the match)
while(true)
{
//Sample code that you'd want to constantly refresh forever — sets the port 1 motor to the right joystick's Y axis on the main controller
motor[port1] = vexRT[Ch1];
//Wait 20 milliseconds to avoid hogging the cortex CPU
wait1Msec(20);
}
}