Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

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
  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

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

sub frame_2
  2 servo

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.


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
split this topic #5

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