User Manual

Just like the sequencing examples above, the script steps through a sequence of frames, but
instead of a timed delay between frames, this example waits for a button press. The
WAIT_FOR_BUTTON_PRESS subroutine can be used in a variety of different scripts, whenever
you want to wait for a button press. You could also expand this example to allow multiple buttons,
continuous motion, or a variety of other types of button control.
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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
?
Pololu Maestro Servo Controller User’s Guide © 2001–2017 Pololu Corporation
6. The Maestro Scripting Language Page 83 of 99