Maping joystick to servos
Dave from United States  [2 posts]
6 years
Is there a step by step guide to setting up joystick control of the mini maestro servos?
Anonymous 6 years

There isn't a step by step guide since the number of steps are not that many. If you download and have a look at


that configures the CoroBot for joystick control. You can remove that module (keeping in mind the left and right motor variables) and replace that with the Maestro module and select the same variables.

The main point of joystick control is to convert the joystick values -1000 to 1000 to the servo range of 500 to 2500. The conversion is normally done in VB and is a quick scale formula that's not too hard to understand.

Hope this helps.

Dave from United States  [2 posts] 6 years
Thanks Steven,

Not knowing VB at all this stuff is over my head however the example you sent me helped in understanding how this is being accomplished, I just need figure out how to code it. I am using two motors as well and I want the joystick to run both motors forward and backward when the joystick is moved forward and backward respectively. I then want to run one motor in forward and the other motor in reverse when the joystick is moved left or right (equal speed).
Here is what I tried and I am not getting it to work.

speed = GetVariable("joy_y")
turn = GetVariable("joy_x")

SetVariable "left_motor", (- turn)-1500
SetVariable "right_motor", (+ turn)+1500
SetVariable "left_motor", (speed) +1500
SetVariable "right_motor", (speed) +1500

Thanks again for your help and super fast response,
Anonymous 6 years

From the robofile above that I mentioned try

speed = GetVariable("joy_y")
turn = GetVariable("joy_x")

SetVariable "left_motor", ((speed - turn)/2)+1500
SetVariable "right_motor", ((speed + turn)/2)+1500

When you use SetVariable with the same variable name you overwrite what you've just set. You have to combine both statements and only set the motor variable once.

Note that this assumes servo values are from 500 to 2500 and NOT 0 to 255.


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index