robot control using controller with 1 analog stick
paddy from Ireland  [4 posts]
7 years
i need help trying to control a robot with a controller that has only 1 analog stick, if the controller is pushed to the right the robots motors have to turn it right and the further right its pushed the faster it turns, the same goes when your turing left forward and reverse. the module has to send out signals from 0-255 to control each of the servos that control the movement of the robot. i have to use vbscript to do this n i know its only simple maths to do this but i just cant figure it out
Anonymous 7 years

I think we may have this in some of the tutorials but basically it will go something like this

speed = 140 ' this is the forward speed that keeps it moving
max_turn = 128 ' this is the max turn speed

turn_speed = (max_turn * (joy_x / 1000))
motor_left = speed - turn_speed
motor_right = speed + turn_speed

assuming you get the joy_x value from your joystick that ranges from -1000 to 1000.

The idea is to scale the amount of joy_x into the max turn value. So when fully left or right the turn speed will basically set one wheel to 0 speed which indicates a maximum

You could use joy_y for the actual speed value (instead of the hardcoded 140) using the same technique.


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