Reposted from the Official Vex Answers forum section:
A potentiometer gets plugged into an Analog input on your microcontroller. It will return a value from 0 - 1023 which correlates to the angle at which the potentiometer is set. You could have your program set to have a different autonomous routine for each of the 1024 different values, like this:
AutoSelector = GetAnalogInput ( 1 );
if ( AutoSelector == 1 )
{
AutonomousOne();
}
else if ( AutoSelector == 2 )
{
AutonomousTwo();
}
else if ( AutoSelector == 3 )
{
AutonomousThree();
}
//etc....
But then even a slight wiggle of your potentiometer would select a different autonomous routine. A better idea would be to divide up your potentiometer readings up into zones or ranges. You could select what autonomous code you wanted to run by turning it to within or before the first third of it’s total range, within the second third, or to within or beyond the last third. You could even put label stickers on your potentiometer or robot to tell which section does which autonomous! Then you might have code that looks like this:
AutoSelector = GetAnalogInput ( 1 );
if ( AutoSelector <= 400 )
{
AutonomousOne();
}
else if ( AutoSelector > 400 && AutoSelector <= 800 )
{
AutonomousTwo();
}
else if ( AutoSelector > 800 )
{
AutonomousThree();
}
//etc....
AutonomousOne();, AutonomousTwo();, and AutonomousThree(); are function calls to functions you could make. You could also just as easily put your autonomous code there instead of those statements, but I would recommend splitting your different autonomous routines into different functions for the sake of readability and clean code.