Servo actuated w/switch open and closed

Greetings,
I have spent many hours looking over your script examples and searching your forum for what i think is a simple task.
I am using a relay switch and your micro maestro 6 to actuate 2 servos. I have been able to move the servos to a new position with each closed switch command. What I would like to have happen is for the servos to move to a position when closed and return when open. The following is a script example I am attempting to edit for my purpose.
Thank you in advance for the help.
Regards, Harold

# Uses WAIT_FOR_BUTTON_PRESS to allow a user to step through a sequence
# of positions on servo 4,5


begin
wait_for_button_press
8000 4 servo
500 delay
8000 5 servo
500 delay
Wait_for_button_press
500 4 servo
500 delay
500 5 servo
500 delay
repeat




# Returns 1 if the button is pressed, 0 otherwise.
sub button
0 get_position 500 less_than
return

# Waits for a button press, with debouncing.
# (Requires the BUTTON subroutine.)
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 pressed
button
if
get_ms over minus 10 greater_than
if drop return endif
else
drop get_ms
endif
repeat

Hello, Harold.

Instead of calling wait_for_button_press in your main loop, try calling wait_for_button_closed_10ms wait_for_button_open_10ms. Does this make sense?

–David

Yes, it makes sense and works perfect. I considered it but wasn’t confident enough to try it.
Thanks for the help.

Regards,
Harold

Can you post your code so I can take a look at it. I am trying to do they same thing, except I am trying to move 8 servos from the neutral position to the max position and then back to the neutral position when I push a button. All I can get it to do it move the servo to the max position and not move back unless I press the button again.

Dan

Never Mind. I knew it had to be something simple. I looked at the original post and figure it out . I have all moving like I want in the control center.

Now to get the actual servos to move.

Back to reading the manual again. Program works but servos don’t move.

Dan