Unnoficial: Help with button programming

I’ll start some things off. Make sure your declarations for sensors are using braces, as well as make sure to not misplace the locations of curved brackets.


if (vexRT[Btn7L] == 1 && SensorValue[potentiometer] < 500)
{
motor[port10] = 84;
motor[port5] = 84;

}
else if (SensorValue[potentiometer] < 2000)
{ 
motor[port10] = 0;
motor[port5] = 0;
} 
else	
{
motor[port10] = 0;
motor[port5] = 0;
}

Also, I think this code would only work inside a while loop. I’m assuming it is, correct?

@[TVA]Connor is correct about the brackets and the while (or similar) loop. Presumably this is one of several commands within a greater while(true) or similar loop for user input. If it isn’t, do that right away. Also, your else if part should be > or >= 2000 and the last else removed, or else you stop when you get to 500. But you’re going to run into problems. Presumably