Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Help with Maestro Script


I’m new to this and am having trouble understanding Script for the Maestro 6
I have the Maestro 6
a Hitec 311 servos connected to channel 5
and I have a GP2Y0D805Z0F sensor connected to channel 4 (Set to Input)
under the Status tab it shows the rotation of the servo
and the sensor reads 255.75 with nothing detected, then reads 56.00 when something is in the detection range.

How do I write the script so that the servos move to 1280 when nothing is detected
then once something is detected by the sensor the servo moves to 1728 for 2500 ms then returns to the 1280 location till something is detected by the sensor again.

Also is their a page or someplace I can go to learn more about what all the terms mean and do?
someplace that brakes it down to simple terms that a complete newbe can understand?
I’ve read through the Maestro user guide and looked at the examples but am even more confused now after doing so.

Thank you


Hello, David.

I am sorry you are having trouble understanding the Maestro Scripting Language. The scripting language is a stack-based language and is very similar to FORTH. You might try searching for more in-depth documentation on FORTH to get a better understanding of the process flow of the Maestro scripting language. You could also try loading an example script and using the “Step Script” button in the “Script” tab of the Maestro Control Center to step through the script line by line and see how the values on the stack change after each command execution.

To help you get started on your script, I recommend that you take a look at the “Using multiple buttons or switches to control servos” example script and try to understand how it works. That example script can be found under the “Example Scripts” section in the Maestro User’s Guide. You can use an IF/ELSE statement to move your servo to the associated position after checking your sensor’s status. Like so:

  #  check if sensor is detecting anything
    # move servo to 1728 us
    # delay 2500 ms
    # move servo to 1280 us

By the way, I noticed you referred to your position values in milliseconds. I think you meant to type microseconds. Typically, standard RC hobby signals are between 1000 and 2000 microseconds.

If you try writing your script and are having trouble getting it to work, you can post your code here, and I would be happy to take a look.

- Amanda


Thank you for your help Amanda
after re-reading and re reading everything several times and using the example you posted I was finally able to understand this part of the script. I still have a lot to learn but at least now I have a starting point.

Thank You