Using multiple buttons or switches to control servos
This script demonstrates how to connect your Maestro to multiple buttons. When a button is pressed, it runs the corresponding sequence.
# When the script is not doing anything else,
# this loop will listen for button presses. When a button
# is pressed it runs the corresponding sequence.
begin
button_a if sequence_a endif
button_b if sequence_b endif
button_c if sequence_c endif
repeat
# 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
return
sub button_b
1 get_position 500 less_than
return
sub button_c
2 get_position 500 less_than
return
# These subroutines each perform an arbitrary sequence
# of servo movements. You should change these to fit
# your application.
sub sequence_a
4000 3 servo 1000 delay
6000 3 servo 500 delay
return
sub sequence_b
8000 4 servo 900 delay
7000 4 servo 900 delay
6000 4 servo 900 delay
return
sub sequence_c
10 4 speed
7000 4 servo 3000 delay
6000 4 servo 3000 delay
return
Please note that this script does not do multi-tasking.
If a sequence is running, the script will not detect
other button presses until the sequence is done.
It is possible to make the buttons operate
independently, but the script would need
to be much more complicated.
Depending on how skilled you are at
writing scripts, you might prefer to use
multiple Maestros instead.