Potentiometer as a Auton Selector

Hi Vexters - we’re having a strange issue I was hoping y’all could shed light on.

W/Cortex for Auton we used a if/else loop to run auto based on the value of the potentiometer.

With V5 we did the same and while the logic echos the correct selection to the controller, the code always runs the first autonomous function regardless of selection:

    autoSelect = Selector.value(analogUnits::range12bit);
    
    if(autoSelect <=800){		//BLUE 2
		autoB(-1);}
	else if (autoSelect >800 && autoSelect <=1500){	//BLUE FLAG
		autoA(1);}
	else if (autoSelect >1500 && autoSelect <=2200){	//NO Autonomous
		return;}
	else if (autoSelect >2200 && autoSelect <=2800){	//RED FLAG
		autoA(-1);}
	else if(autoSelect >2800){						//RED FLAG
		autoB(1);}
	else{															//catch all
		return;}//neutral position

a separate task runs same code but exchos which auton is selected to the controller:

        autoSelect = Selector.value(analogUnits::range12bit);
        
        if(autoSelect <=800){		//BLUE 2
            Controller1.Screen.print("BLUE 2");}
        else if (autoSelect >800 && autoSelect <=1500){	//BLUE FLAG
            Controller1.Screen.print("BLUE FLAG");}
        else if (autoSelect >1500 && autoSelect <=2200){	//NO Autonomous
            Controller1.Screen.print("NO AUTO");}
        else if (autoSelect >2200 && autoSelect <=2800){	//RED FLAG
            Controller1.Screen.print("RED FLAG");}
        else if(autoSelect >2800){						//RED 2
            Controller1.Screen.print("RED 2");}
        else{															//catch all
            return 0;}//neutral position

You can use the touch screen much more effectively to set auto features:
WalshBots autonomous feature selection

1 Like

WOW - this is SWEET! THANK YOU!

Thank James Pearman for the button code, we just extended it so it flows better with coding.