pre-auton and auton selection

Hi everyone, i have an idea for a new routine selection using a spare encoder that i have, plan is to write a routine so when you turn a sprocket it changes the value of an int. which then in turn changes the routine (will use the speaker to determine the autonomous routine enables)

  • so … some questions questions.

when does pre-auton work … ? when is it available … ? so like is it available when joysticks are available, or is it always available ???

cheers …

What do you mean by “pre autonomous”? Do you mean before the match starts?

Our team has multiple autonomous programs that we switch on and off by Limit Switches held down by adjustable switches. I know that there are other ways to do it too, like with a potentiometer.

I believe the pre-autonomous code runs when the robot and joystick are turned on and connect.

What I would recommend for autonomous selection is using a potentiometer and code in your autonomous routine like this:

if (potentiometerValue > NUMBER1) {
else if (potentiometerValue > NUMBER2) {
else {

This way whatever autonomous you have set will run at the start of autonomous, regardless of whether the robot is on or not when you set it.

Our team has something similar, although instead of a potentiometer, we use limit switches and a bunch of if-statements.

The link below is an old post that gave some explanation of how the ROBOTC competition template works, there’s not much magic to it, it contains the main task and runs pre_auton before going into a loop waiting for the competition state to change.

Ok thanks for the help, worked out how to do it now with all the help

cheers :smiley: