One of our teams created the below program to run different sets of commands. They are trying to release the bonus tray.
Pressing button 1 starts the first set of code.
Pressing button 2 starts the second set of code, but will only work after program 1 has run.
How should the program be changed so they can run either set of commands?
Program logic
Stretch robot being used to push levers on bonus tray
Team presses first LED and robot moves to push first bonus tray button
Robot is picked up and returned to starting point
Team presses second LED and robot moves to push second bonus tray button
You might need to use a forever loop and if commands. Try something like the attatched. The loop goes round forever waiting for you to touch one of the LEDs. When touched, the commands inside the relevent if are executed. When they are finished, the loop continues and waits for another LED to be touched. This means the order in which they are touched does not matter.
Let’s say the teams wanted to stop one of the loops to restart it… For example, they already ran the first command successfully and are trying for the second. They miss the alignment when they start the second command and need to break the loop and restart quickly. Would it be possible to have a third button that would exit the loop without having to restart the program?
I tried searching for this in the robotc help, but continue and break are missing… I get break;, but I’m not familiar with continue. I can get an idea from your program, but is there any documentation on this?