Hello! Basically, my code is running multiple times for one call.
This is my called function
void r1p(){
r1var += 1;
cout << r1var << endl;
}
Controller1.ButtonR1.pressed(r1p);
Yet when I press R1 once (not held), the variable r1var iterates 18 times, and gets printed 18 times.
The length of how long I hold the button does not affect the times, but it always specifically runs 18 times.
It does not seem to be a controller issue, as the same thing happens with a different controller.
I’ve temporarily solved this issue with
if((r1var / 18)% 2 == 0){
flMotor.spin(vex::directionType::fwd,0,vex::voltageUnits::volt);
} else{
flMotor.spin(vex::directionType::fwd, 8.5,vex::voltageUnits::volt);
//flMotor.spin(vex::directionType::fwd,6.2,vex::voltageUnits::volt);
}
}
It works, but now I am just curious on why it runs such a specific number of times. I am in VEXcode.