Micro Maestro simple program help please!

Hello, im working on a project that is not too complicated but frankly CODE writing is something i know nothing about, now i could learn and hope too someday but for now im hoping someone can help me get going. Im working on a reseting target were after a row of targets fall (5) it will complete a circuit via 5 depressed micro switches hopefully to trigger the maestro to go through a simple servo sweep AND energize a 5v relay (pololu) while going through the servo sequence. I would also like to use the maestro to do the same for one other target unit independently . I am aware that the maestro can not multitask but im thinking that each target unit will not be “triggerted” at the same time. so… one channel button press…activates servo sequence while energizing relay for same amount of time servo sequence is in progress x 2 thanks for any help !! questions ?

UPDATE on my post…i forgot to mention, i found a script on a forum for the servo and button push someone had created for the same pupose of target reset and shared for all , my situation though calls for the need to " switch off " a micro switch triggered system for sound effects WHILE the entire set of five targets are being reset so as not to trigger the sound effects while the targets are being reset thus passing over the micro switch during reset. hope that makes sense. so…target falls…passing and triggering micro switch ( sound effect ) …after all five fall and trigger their individual sound effect…AND signal.the sevo resets the five targets mechanically …while a relay is energized it will prevent sound effects to be triggered during reset…hope this all makes sense…thanks for any ideas !!!

From your title, it sounds like you have a Micro Maestro. Is that right? Generally, if you want to monitor the state of a switch, you will need to dedicate a channel on the Maestro to reading it. (So, you will not be able to use that same channel to also control a servo or serve as a digital output.) The Micro Maestro only has six channels, and it sounds like you need more than that to get all of your system working.

What have you done so far to build your system? Do you have a Maestro already (if so, can you verify which one you have)? Can you post a schematic of your proposed or current connections? What kind of signal does your sound effects system need? If you do not know, it would help to provide a link to a product page for the system. Also, if you have your system already connected and set up and are currently trying to write a script, what specifically are you having trouble getting started on?


Thanks Jon for your reply. I have a micro maestro. (very cool BTW) I try to explain things a little more. This work in progress is a BB gun target for the grandsons. Bits and ideas from other makers led me to incorporate some of my amateur animatronics stuff. I am hoping to use ONE micro controller Micro Maestro to " reset or stand up two separate banks or rows of targets After posting this yesterday i discovered i can use another servo as a physical switch to disable sound effects during the reset seq.
This is all in the early stages of development but here is were i am at…a hinged small target will fall backwards when struck by a BB. AS it is falling, it will physically pass over a micro switch triggering a separate function IE…sound effect via a robertsonic wav trigger ( i have) that will be powered separately. When it hits the bottom or completes falling it will lay on a micro switch, when all five targets in that bank complete this falling, sound triggering and laying on a switch it will then complete a circuit to “button press” and with a resistor cause a channel on maestro to go low and start servo movement on another channel to reset the target. NOW HERE IS were i am still unsure … I have a pretty good script for the servo to raise the targets AND now i think i can use THAT servo or another servo arm to physically switch off or make open the wav trigger inputs so as it is raising the targets all sounds will not be triggered during reset as they pass the switch on the way up.The WAV trigger is polyphonic so that would sound like a war zone! hope that makes sense. My head scratch now is…how do i make button 0 trigger servo 1 and button 2 trigger servo 3 ? even though the function and rotation of both servos are the same i want each target to reset individually … now i have read that the maestros can only do one sequance or script at a time and i get that, but for the reason of conservation and simplicity of design i would like to only use one controller for both target banks in thinking that only one will complete its circuit at a time. This way basically each grandson has his own side of the target banks and only resets his side when all “his” five targets fall So in conclusion… can i assign button presses to different servos ? and how ? Thanks !!

Yes, using the Maestro scripting language, you can link specific button presses to specific servo actions. And you are right, you can only have a single script on the Maestro. What you will need to do is create a subroutine for each servo movement and then you can trigger the subroutines from specific button presses. You can find an example of how to create a subroutine under the “Compressing the sequence” subsection of the “Example Scripts” section of the Maestro’s user’s guide. You can find the guide under the “Resources” tab of any Maestro’s product page. You might have already found this, too, but an example for incorporating a button press into your script can be found under the “Using a button or switch to control servos” subsection. Since this is new to you, you might get started by writing a single subroutine that is triggered by a single button press, using some movements you have already predetermined (like the raising the targets script you have already written). If you get stuck, post what code you have tried, what you expect it to do, and what it is actually doing, and I’ll see if I can help.


for some reason wait_for_button_press comes up as an error now any ideas? i have tried reseting everything even just copy and paste example scripts with " button press" and i still get the error

if its not too much to ask…really all i need is servo 1 on channel one to move from default value(992) to 2200and then back to 992 rest until button push restarts sequence could you do a sample script for me? button on channel 0

It sounds like the behavior you want can easily be achieved with some small modifications to the “Using a button or switch to control servos” script found in the “Example Scripts” section of the Maestro user’s guide. This script waits for a button press and moves a servo (on channel 1) to the specified position, then repeats the process with a different specified position. It isn’t clear how long you want the servo to stay at the 2200us position, but modifying the main_loop to something like this should work:

  wait_for_button_press    #call the wait_for_button_press subroutine
  8800 1 servo    #send the servo to 2200us
  3000 delay       #delay for 3 seconds
  4000 1 servo   #send the servo to 1000us

If you try this and have problems making the modifications, can you post the complete script you are using? Also, if you receive errors when running the script, can you include a list of the errors being shown in the “Errors” tab of the Maestro Control Center?


For some reason of my own ignorance of code/ script i could not get wait
-_for_button_push to work as in the script you mentioned above or any otther form BUT ultimately a modified sample script of " multiple button press" in user guide seemed to doo the trick for me… i eliminated the other buttons and tweeked button a and servo a values and im good to go ! thanks to both you and Jon for your help. Im very greatful for your responses and help ! here is my final script for my self reseting target for my grandsons bb gun using the micro maestro …

# this loop will listen for button presses.  When a button
# is pressed it runs the corresponding sequence.
  button_a if sequence_a endif
# These subroutines each return 1 if the corresponding
# button is pressed, and return 0 otherwise.
# Currently button_a is assigned to channel 0, 
# button_b is assigned to channel 1, and
# button_c is assigned to channel 2.
# These channels must be configured as Inputs in the
# Channel Settings tab.
sub button_a
  0 get_position 500 less_than

# These subroutines each perform an arbitrary sequence
# of servo movements.  You should change these to fit
# your application.
sub sequence_a
2200 delay
  8500 3 servo 1000 delay
1000 delay
3900 3 servo 3000 delay

I am glad you were able to get it working how you want; thank you for letting us know and sharing your code! It sounds like a really fun project; you might consider sharing it in the “Share your projects” section of the forum.