I made the the buttons in the 7th and 8th channel make the robot flip it’s direction, but it is not working everything and there seems to be a delay. Please tell me if the part of my code is correct.
int reverse = 1;
while(true){
if(vexRT[Btn7U]){
if(reverse == 1)
reverse =-1;
if(reverse==-1)
reverse = 1;
// Rest of the code
Both if statements will execute when the button is pressed. Initially reverse will be 1 and changed to -1, then when the second if statement is evaluated reverse will now be -1 and changed back to 1 again.
As a minimum, at least include an else statement before the second if.
int reverse = 1;
while(true){
if(vexRT[Btn7U]){
if(reverse == 1)
reverse =-1;
else
if(reverse==-1)
reverse = 1;
// Rest of the code