Repeat servo positions until button press

I have a mini maestro 12 and I am creating a custom script for an autonomous robot. I have all the Servo positions and sequins working great so the robot is moving exactly how I would like it. The issue is I need a push button to start a repeating sub routine and run until another button is pressed which will start another repeating subroutine. I have two issues how do you simply repeat a subroutine over and over after an event like a button press and how do you keep that separate team repeating until another input is true ? Thank you very much for your time and any response !

Hello.

It sounds like you want to be able to interrupt a looping subroutine with a button push. Since the Maestro scripting language does not allow for interrupts and your subroutines are likely using blocking delays, it would be difficult to implement something like that reliably in a Maestro script. For example, if you used a while loop that only ran while the button was not being pressed, in order to break the while loop, the button would have to be pressed at the beginning of each loop, which might only occur once every few seconds depending on your loop.

The easiest way to implement something like that is probably to use a separate microcontroller (such as an Arduino or an Arduino-compatible A-Star 32U4 programable controller) to read the button inputs and send the “Restart Script at Subroutine” serial command to the Maestro (which can be sent at any point during the loop of the script). More information about this serial command can be found in the “Serial Script Commands” section of the Maestro user’s guide, located in the “Resources” tab of the Maestro product page. When the Maestro receives this serial command, it will stop the current script and restart it at the specified subroutine.

Brandon