How would i trigger a sequence with a button (mini maestro 12)

I need to trigger a script with a button Ive already got it soldered on with the resistor etc. It works and i tested it on the example button script. I cannot figure out how to get this to active a sequence script. Can someone please post an example script for this that i can (hopefully) just paste in my example script. I tried pasting my sequence into the bottom of the button example script in place of the frames it has default however it would not return to start position. What i need is for it to activate the first step of the script when i push a button. Then the next step when it is pushed again. Then the final step in which it returns to original position. Basically each time i push the button it does a step. Sequence script is pasted bellow. This is my first post so i hope it formats correctly. (EDIT) The button is on channel 0
Thank you-James

# Sequence 0
begin
  500 0 4544 0 0 0 0 
  0 0 0 0 0 frame_1..11 # Frame 0
  500 2752 frame_2 # Frame 1
  500 4544 frame_2 # Frame 9
repeat

sub frame_1..11
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  delay
  return

sub frame_2
  2 servo
  delay
  return

Hello, James.

Probably the simplest way to start your script with a button press is to add a WHILE loop to the beginning that exits when the button is pressed. You can find some code for doing this in my post here. Please note that the code there is for a button on channel 5; you can change the 5 to a 0 to make it work for your button on channel 0.

If you put the WHILE loop before your BEGIN/REPEAT loop, the sequence will repeat forever once the button is pressed. If you want the sequence to wait for the button every cycle, you can put the WHILE loop inside of your current BEGIN/REPEAT loop.

Brandon

1 Like

Thank you this worked perfectly.

Err… this is embarrassing. I think im missing something but… when connected to usb it works perfectly, however when i unplug it it lights up the error light and doesn’t work (also the servo vibrates a bit). The script is set to run on startup and have tried both 4 AA batteries and 6v from a lab power supply. I read through the manual and was unable to find the issue. I also tested it with just a sequence back-and-forth script and that didn’t work either. I do have the blue jumper connected.
EDIT: Apparently i wasn’t providing sufficient amperage i dialed it up to 2 amps and it works fine.

1 Like

A post was merged into an existing topic: Pausing Maestro script

Brandon,
Can I ask what you mean when you say “inside” of the BEGIN/REPEAT loop?
I’m still having no luck getting the script to start when I toggle the switch on (pulling input pin 8 low), play one sequence, then wait until the switch is toggled off (pin 8 high), then on again before it plays the sequence once more. this is my current script

Sequence 0

begin 8 get_position 200 less_than while #switch low to start sequence
repeat
begin
3000 3986 3986 3986 3986 0 0
0 0 0 0 0 frame_0…7_9…11 # Frame 0
3000 8000 frame_0 # Frame 1
3000 3986 frame_0 # Frame 2
repeat
begin 8 get_position 200 greater_than while #switch high before restart switch low possible
repeat

I know something is wrong but I can’t figure it out
Tim

Hello, Tim.

I responded to your post back on the original thread we were discussing this on. Let’s continue our conversation there:

- Patrick