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

Maestro digital inputs from arduino digital outputs?


Hey everyone, I am currently trying to send data from arduino’s digital outputs to the maestro’s digital inputs. I can get high/low values to go through and cause the maestro to read values of either 0 or 255, but when I output PWM values (0-255) the input is glitchy and jumps back and forth between 0 and 255.

My end goal is to have several servo sequences saved on the maestro controller and then call certain ones based on digital input values that are coming from the arduino (since I don’t really want to deal will sending serial data back and forth through processing). One workaround would be to have 5-6 digital inputs that only read 0 or 255 and have those trigger sequences, but I would love to just have one digital input whose value I can control between 0-255 to then create trigger ranges (for example, values of 0-50 triggers one sequence, etc.)

Just FYI, I am using the Firefly interface to control arduino if that makes a difference.

Does anyone have any tips? Any help is appreciated.


edit: I do have the inputs on channels 12+, just fyi


For your application, serial is most likely the best option instead of general-purpose digital I/O. You don’t have to send data “back and forth”, you only have to send it one way to achieve what you want. The NewSoftSerial library makes it easy to designate any of the pins on your Arduino as a serial TX line and use it to send commands to the Maestro. The Maestro has a command for running a subroutine (Restart Script at Subroutine) so you can just send that command. What you would do is put the Maestro in to the right serial mode (UART, fixed baud), configure the Maestro and Arduino to use the same baud rate, connect the Arduino’s TX to the Maestro’s RX, connect the GNDs together, and then send the right sequence of bytes. The bytes for the Restart Script at Subroutine command are documented in the Serial Script Commands section of the Maestro User’s Guide. To help you get started on the Arduino code, you should look at Xevel’s Micro Maestro Arduino code. That code was written for the Micro Maestro, but the Mini Maestro’s serial commands are superset of the Micro Maestro’s, so it should work fine for you.

The Arduino’s libraries can cause confusion here: “analogWrite” is poorly named because it does not actually set an analog voltage level on the pin, but in fact it generates a digital PWM signal on the line; the line rapidly switches between 0 and 5 V. That’s why the input the Maestro is detecting jumps back and forth between 0 and 255. You could add an RC filter to turn this PWM signal in to an analog voltage. That would probably work for you as long as you don’t need too much resolution, but you must program your Maestro script so it can handle intermediate voltages correctly (since switching the voltage level will not be instantaneous).

Then you are using digital inputs, which is wrong for you what you are trying to do because they can only read as 0 or 1023 (displayed as 255.75 in the Maestro Control Center). You want analog inputs. See the Channel Settings section of the Maestro’s guide to understand the different between analog and digital inputs. But really you should try to use serial instead (see above).



Thanks a lot for your help, I really appreciate it.

I m wondering though how the serial data that the maestro receives can be accessed through the scriptor?

As of now using the digital input the code is something simple like this:


23 get_position
dup 175 less_than
dup 176 greater_than

So I guess I’m just not sure where the maestro take the RX data and how I can easily access it in a script.




Please read the documentation of the Restart Script at Subroutine command that I linked you to to learn how that command affects your script: