Arduino, ps2 joystick , differential steering

Hi!

Im looking for some help with differential steering, i have a ps2 controller hooked up to an arduino and working but i cant figure out how to convert x,y from the joystick into steering with 2 motors.

I could hack it and create “zones” but im sure theirs a more elegant way.

I have searched but cant find a solution, Im sure theirs a algorithm for it out there somewhere.

Thank you so much in advance for your help!

1 Like

Hi @adambrum

What are you using to control the servos exactly? Is it the Arduino directly?
You can use the following link as a tutorial:

Its more the maths to convert joystick to "tank " drive,

for example
joystick forward = both motors forward
joystick right= left motor forward, right motor backwards

sin and cosine are your friends

Assuming your numbers from the joystick give positive X to the right and negative X to the left, positive Y forward (up), negative Y backward (down), you might try this:
leftMotorSpeed = Y+X
rightMotorSpeed = Y-X

I haven’t tried this. I just came up with it. So who knows…