Can somebody make a script for maestro 6ch for me?

I am interesting for a script.
I have a button on channel 5 and a servo on channel 0.
When i press the button i want the servo opens
when i press the button again i want the servo close
the third time i press the button i want to delay 60-90 secs and then open. It will be good on thrid push the red led to turn on .

It will be the best if i press the button for 10 secs to changes the delay from 60 sec to 90 and etc.

thank you.

Have you tried writing the script that you described? It sounds like you could use the wait_for_button_press subroutine in the “Using a button or switch to control servos” heading of the “Example Scripts” section of the Maestro user’s guide to have your script wait for the button presses. For doing a longer delay, like 60 or 90 seconds, you can use the method in the “Long delays” heading of the same section.

I would suggest starting without the 10-second button hold to change the delay until after you get a working script. If you try writing your own script and run into problems, you can post what you have so far here, and I would be glad to take a look.

Brandon

i check the examples there but i cant succed it … Anyway was a projecto to take with me tommorow on holidays i need it for a certain purpose. It was a fast looking and i need it fast. I will look them again when come.

ok i have a question

goto main_loop    # Run the main loop when the script starts (see below).
 
# This subroutine returns 1 if the button is pressed, 0 otherwise.
# To convert the input value (0-1023) to a digital value (0 or 1) representing
# the state of the button, we make a comparison to an arbitrary threshold (500).
# This subroutine puts a logical value of 1 or a 0 on the stack, depending
# on whether the button is pressed or not.
sub button
  0 get_position 500 less_than
  return
 
# This subroutine uses the BUTTON subroutine above to wait for a button press,
# including a small delay to eliminate noise or bounces on the input.
sub wait_for_button_press
  wait_for_button_open_10ms
  wait_for_button_closed_10ms
  return
 
# Wait for the button to be NOT pressed for at least 10 ms.
sub wait_for_button_open_10ms
  get_ms # put the current time on the stack
  begin
    # reset the time on the stack if it is pressed
    button
    if
      drop get_ms
    else
      get_ms over minus 10 greater_than
      if drop return endif
    endif
  repeat
 
# Wait for the button to be pressed for at least 10 ms.
sub wait_for_button_closed_10ms
  get_ms
  begin
    # reset the time on the stack if it is not pressed
    button
    if
      get_ms over minus 10 greater_than
      if drop return endif
    else
      drop get_ms
    endif
  repeat
 
# An example of how to use wait_for_button_press is shown below:
 
# Uses WAIT_FOR_BUTTON_PRESS to allow a user to step through
# a sequence of positions on servo 1.
main_loop:
begin
  4000 frame
  5000 frame
  6000 frame
  7000 frame
  8000 frame
repeat
 
sub frame
  wait_for_button_press
  1 servo
  return

On main loop begin


repeat

i see 4000 frame
5000 frame etc

how i can change this one command with multi commnds on one press button?

There are a lot of ways you could use a combination of the wait_for_button_press with another subroutine to do multiple commands with 1 button push.

The main_loop in that script puts a position value on the stack (e.g. 4000, 5000, 6000), then calls a subroutine named frame. This subroutine calls another subroutine called wait_for_button_press, which stays in a loop constantly checking the button until it is pressed before returning back to where it was called. After that, the position value that was placed on the stack is sent to the servo on channel one (e.g. 4000 1 servo will set the servo on channel one to a position of 4000).

If you wanted to set targets for multiple servos or add something else like a delay, you could add the commands after the wait_for_button_press in the frame subroutine and send the parameters to the commands with the position value. For example, I modified the main_loop and frame subroutine to add a delay after setting the servos position and copied it below:

main_loop:
begin
  1000 4000 frame  #the 1000 in this line is passed to the delay command in the subroutine to do a 1 second delay
  1000 5000 frame  #1000 is passed to the delay command to do a 1 second delay
  1500 6000 frame  #1500 is passed to the delay command to do a 1.5 second delay
  2000 7000 frame  #2000 is passed to the delay command to do a 2 second delay
  2000 8000 frame  #2000 is passed to the delay command to do a 2 second delay
repeat
 
sub frame
  wait_for_button_press
  1 servo  #the top value of the stack when this subroutine is called is used as the target position
  delay     #the next value is used for the delay
  return

Brandon

thank you Brandon I will study this to make what exaclty i want.