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

Pololu Forum

More info meastro servo controller


I was getting a lil ahead of myself there with “if” statements right now. I think i need to concentrate on my PS2 controller dilemma.

Ok so after doing some reading and some looking up i found out that the numbers after the buttons on the library.h for the arduino part are the byte packets sent through the serial.

My question is… If the bytes sent are in this exampl… 0x0000 and the pololu needs commands like this example 0x00. Do i need to set the byte packets sent the latter protocol or will the Pololu automatically understand the command.

Ok the first byte sent should be the Baud rate in Pololou protocol?

In my PS2 handle code it sets the serial baud rate to 57600, does this number need to be changed to pololu command protocol or does it always have to recieve 0xAA



If you look at the “Script” example from the Pololu Maestro Arduino library, lines 30 to 51 contain code that is meant to go into the “Script” portion of the Maestro Control Center software and be uploaded to the Maestro. This code contains two different prewritten subroutines (which in these cases are sequences of servo movements that have been put into the script). They execution of the script on the Maestro is controlled by the statements on lines 87, 91, and 99.

The Maestro and the Arduino communicate with each other over TTL Serial. Essentially, the Arduino sends a sequence of digital bits over the line connected to the Maestro when the statements noted above (lines 87, 91, and 99) are executed.

In general, you will probably want to write code for the Arduino that looks at the state of your PS2 controller and if one of the buttons is pressed, executes the maestro.restartScript(i); command, which will send the appropriate serial command from the Arduino to the Maestro.


Ok you said lines 87, 89 and 99 are my activation functions, the integer in the parameters would be the subroutine im calling. Ok so do i call a serial read Function call to listen for each button press?


Ok been doing alot of reading and came up with the code im posting below. Please dont make fun of me ive never actually written my own code before so o know it might be a lil mixed up.

Basically im opening the pololu serial and telling it listen for a byte with the serial.read function. If it reads 0x0008 or the up button on the PS2 cotroller it activates subroutine 1. If it reads no signal then it stops subroutine 1.

#include <PololuMaestro.h>

#define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(10, 11);

void setup() {


void loop() {

Serial.read(); //open serial port

if (serial.input = 0x0008); // up button Ps2 handle

maestro.restartScript(1); // starts subroutine 1

else if (serial.input = 0x0000); // when buuton is released stop script

maestro.stopScript(1 maestro.restartScriptWithParameter(1, 2000);

} [/code]


It looks like you have the right idea of reading an input from your controller and then sending a command to start the appropriate script on the Maestro, but I would not expect that code to work. The language that the Arduino uses is C++ and it might be helpful for you to find an online tutorial or course for that. For instance, boolean comparisons like the ones you are using in your if statements in C++ require the ‘==’ operator since ‘=’ is the assignment operator (to make one thing take the value of the other).



Oh i have been using a C++ tutorial. Is there some links to the code library for the pololu. Something with the keywords and definitions and stuff?

Ive been reading the basics but it would make it easier if i could look at all the commands and functions. Then i wouldnt have to make guesses.


There is documentation for the Maestro Arduino library on its GitHub page. You can click the “Classes” tab at the top to see the available objects, methods, and functions.



We will come back to the PS2 support.

Ok when using the sequencer, there is always a pause between each frame which makes it jerky when i moves.

Is there a way using the sequencer to say take each leg and lift and rotate it and drop it then have it come full reverse at a specific amount of time then do each other leg the same so theres no pause between each movement.


Tell you what.

Since there is no current code to support the PS2 handle, i will give yall my code or share it so any one wanting to do the same can do it with out all the hassle.

I just need a lil extra help. Maybe we can get some team action going?

I followed the link you gave but its for the arduino pololu libraries. You said the code needed to be C++. Where are the C++ libraries.

Just wondering but the scriptino code (that goes in the script) used to activate the subroutines needs libraries to work right. Are the arduino libraries already included with the software. How does that work?


I do not know of anything inherent in the Maestro that would require motion to pause between frames. I made a post in this thread earlier that discusses how to adjust the length of time between starting frames.

The Arduino libraries I linked to in my previous posts are written in C++ and there should be no need to find separate libraries. The Maestro script code is native to the Maestro and does not require any special libraries.