User Manual

It is a good idea to try stepping through this script before doing anything further with scripts on the
Maestro. In particular, pay attention to how the command “100” puts the number 100 on the stack,
and the DELAY command consumes that number. In the Maestro scripting language, arguments to
commands always need to be placed on the stack before the commands that use them, which makes
the language seem backwards compared to other languages. It also means that you can arrange your
code in a variety of different ways. For example, this program is equivalent to the one above:
The numbers are placed on the stack at the beginning of the loop, then consumed later on in
execution. Pay attention to the order of the numbers used here: the 900 goes on the stack first, and it
is used last.
A simple servo sequence
The following script shows how to direct servo 0 to five different positions in a loop.
The serial mode must not be set to detect baud rate for this script to work. In detect baud
rate mode, the Maestro does not enable any of the servo outputs until the start byte has
been received.
1
2
3
4
5
6
7
# Blinks the red LED once per second.
begin
led_on
100 delay
led_off
900 delay
repeat
1
2
3
4
5
6
# Blinks the red LED once per second.
begin
900 100
led_on delay
led_off delay
repeat
1
2
3
4
5
6
7
8
9
10
11
12
13
# Move servo 0 to five different positions, in a loop.
begin
4000 0 servo # set servo 0 to 1.00 ms
500 delay
5000 0 servo # 1.25 ms
500 delay
6000 0 servo # 1.50 ms
500 delay
7000 0 servo # 1.75 ms
500 delay
8000 0 servo # 2.00 ms
500 delay
repeat
?
?
?
Pololu Maestro Servo Controller User’s Guide © 2001–2019 Pololu Corporation
6. The Maestro Scripting Language Page 78 of 102