Mapping potentiometer values

Hello, I am using a 5k ohm potentiometer with a range of 0-256 and I am using a servo which I have set the min and max at position 658-758 respectively. How would I go about mapping my potentiometer signals to correlate with the servo ranges?

I am running off of script and not through USB connection.

I look forward to any suggestions,

Thank you!

Xia Collier

Hello.

It isn’t clear what product you’re using, but it sounds like you might be referring to the Maestro servo controller. If that’s the case, you can use the “Using an analog input to control servos” example from the “Example scripts” section of the Maestro user’s guide as a reference.

Essentially, in the script, the input will correspond to numbers from 0 to 1023 and you can use a combination of the math commands (minus, plus, times, divide) to map it to the range you want. Please note that the servo target values in the script are in units of quarter-microseconds, so if you wanted to set the target to 1500µs, you would use a value of 6000 quarter-microseconds in the script.

By the way, it is not clear what the units are of the 658-758 range you gave, but it seems very small and also well outside of the standard pulse width range for servos (1000-2000µs).

Brandon

1 Like