Hi, my bot has a catapult for launching discs, so the idea of my code is to launch some discs and then bring the catapult back to a specific position. That specific position is marked with a limit switch, so the code is supposed to start the match with the catapult down in the load position, hitting the limit switch, and when a button is pressed, shoot the catapult and automatically keep spinning the motor until it hits the limit switch and is back in the loading position. When the code is run, the catapult immediately goes into the loading position, but when the button is pressed, the catapult shoots repeatedly. I was wondering if someone could help me out. Thanks in advance!
Here is an example of what the code looks like for reference:
bool shooting = Controller1.ButtonX.pressing();
bool loaded = false;
// If we aren't actively shooting, then run the motor to load it
while (!loaded && !shooting) {
if (LimitSwitch.pressing()) {
loaded = true;
Catapult.stop(hold);
} else {
Catapult.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
}
}
// If we are shooting then the catapult motor stays running until the limit switch is pressed.
while (shooting) {
Catapult.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
}