Here is a photo of our switch from last year, which was connected to the RC. It’s a six position switch with five 22k resistors (100k / (# positions - 1) = 20k, 22k was the closest we could find at Radio Shack). The switch positions were then 0k, 22k, 44k, 66k, 88k, & 110k. This would give analog values of about 0, 205, 410, 615, 820, and 1024. In the autonomous code, we looked for a range of 205, centered on each of those values.
Code:
void User_Autonomous_Code(void)
{
.
.
.
switch (((Get_Analog_Value( rc_ana_in01 )+100)/205)+1) //read autonomous switch
{
case 1: //switch position 1
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
break; //end of case 1
case 2: //switch position 2
.
.
.
default:
{
// something's wrong - do nothing
}
} //switch
} //User_Autonomous_Code