Connect 2 servos more in the exist program

Hello everybody and Happy New Year!!!
I’m writing to you because i’m filling really comfused!!
It’s my first time that i use maestro boards and servos and i will apriciate if somebody can help me!
Below as you can see i have the program which moves two servos, if you push the button.
I would like to add in my program two more sevos which the first one i would like to move it continuously in one direction and the second one i would like to move it 45 degrees forward-backward continuously.
My problem is that i can’t to do all the movements together, i can do it only seperately.

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
  wait_for_button_press
8000 1 servo 8000 2 servo
3000 delay
6000 1 servo 6000 2 servo
4000 1 servo 4000 2 servo
3000 delay
6000 1 servo 6000 2 servo
repeat

sub frame
  wait_for_button_press
  1 servo
  Return

I’m waiting news from you!
Kind Regards
Panos

Hello, Panos.

It will be difficult to do both of those things at the same time with a single Maestro script. If you want the script to be moving 2 servos while also monitoring for a button press and running a sequence with a second pair of servos when it is pressed, you would need to get rid of any blocking code, such as the DELAY command. You might be able to write a script using the GET_MS command to handle the timing of things, but it would not be trivial.

David’s post in this thread has some example code he made showing how you could run multiple sequences concurrently like you are describing, so you could try using that as a starting point. Please note that since that script uses the peek and poke commands, you will need a Mini Maestro (not the 6-channel Micro Maestro) for it to work.

Brandon

Dear Mr. Brandon,
Thak you very much for your fast response to my issue!
I apriciate it a lot!
As i understand, the best solution is to buy a mini maestro for my application and to do everything more easy.Νevertheless, i will try also as you propose me the GET_MS command to handle the timing only for practice,to see the results!

Thanks again.
Regards,
Panos