Problem with Arduino and Maestro communication

Hi everybody,

I have been surfing through this forum and related problems for quite some time now but so far could not figure out a solution for my project. I am using an Arduino Uni with a MiniMaestro shield and 24 servo motors. I am as new to Maestro as to Arduino, so forgive me if I am not using the right terms for describing.
I set up the motors and the shield and it works perfectly fine to play sequences over the Maestro Control Center. The communication between Arduino and Maestro as performed in the example sketches works fine as well.

What I am trying to achieve is an autonomous motor choreography, for which I am using a Cellular Automata that is created in the Arduino Code. (Later in the project I would like to connect a sensor to impact the motors position) So the 24 digits (1 or 0) of the CA translate into targets for each motor (called startangle and endangle). In the Serial Monitor it looks perfectly fine, but I am having problems communicating that to the Maestro. With the code below, some of the motors do shake a little bit; with other tryouts I have gotten less movement and the red light and error code 0011.

What am I doing wrong, what is missing?
Thank you very much in advance!!

cellularautomata_workon.ino (3.3 KB)

Hello, Karmen.

I noticed at least two significant issues with your program:

First, you are declaring an array of servo numbers as strings and trying to pass that as the channel number argument to the Maestro functions, which expect a single channel number as an integer. Even though it compiles, that isn’t going to produce the outcome you’re looking for. (If you have the “Compiler warnings” setting in the Arduino preferences set to anything other than “None”, you should see a warning about it - warning: invalid conversion from 'char**' to 'uint8_t {aka unsigned char}' - which is a good indicator that the code probably won’t do what you expected.) You already have a loop where you’re incrementing the variable x from 0 to 23, so you can simply use x as the first argument instead:

  for (int16_t x = 0; x < width; x++) {
    maestro.setSpeed(x, 10);

Second, there are a few places where it looks like you’re trying to call the setTarget() function, but what you have in your code is not the right way to do that. The setTarget() calls should look a lot like the setSpeed() call above:

maestro.setTarget(x, startangle);

It looks like you have a lot that you’re trying to get working, so an alternative approach I suggest is to start with one of the example programs included with our Maestro Arduino library and gradually modify it toward your end goal. For example, you could start with the “Basic” example sketch and verify that it works with a single servo as-is, then try to change it so it works with two servos.

Additionally, you might consider looking for some online resources or books to help you get some familarity with C++ programming, or trying to find someone with programming experience who can help you with your project.


Hi Kevin,

thanks for your response!
My main concern was that I was that I was missing something from the maestro side. But since it is the C++ code that is weak - I will try to sort that out with some more experienced helpers.
Thanks a lot!