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

Flipping the script


hello everyone,
i have a script i stole off of the script examples for the maestro.

# Sets servo 0 to a position based on an analog input.
  1 get_position    # get the value of the pot, 0-1023
  4 times 4000 plus # scale it to 4000-8092, approximately 1-2 ms
  0 servo           # set servo 0 based to the value

im using this for a go kart i built. i have a mega servo for the steering and a pot.at the end of my steering shaft putting the input into my maestro.
when i turn the steering wheel left the wheels go right. and when i turn the steering wheel right the wheels go left.
is there anyway to correct this.?


Hello, Marcus.

The way that example script works is that it takes the analog input connected to channel 1 of the Maestro, which is read as a value between 0 and 1023, and maps it to a target value (in quarter-microseconds) from 4000 to 8092. There are a few ways to reverse the extremes of the servo (so that 0 corresponds to 8092 and 1023 corresponds to 4000). One way would be to change the line of code that maps the target value (4 times 4000 plus) to something like:

4 times 8092 swap minus

This modified code should effectively multiply the input value by 4, then subtract it from 8092, resulting in target values between 8092 and 4000 as the input changes from 0 to 1023.

By the way, it sounds like you might be using this to control a full-sized, ride-on go kart. If that is the case, please note that we do not recommend our products be used in projects where failure can lead to injury or property damage.