PDA

View Full Version : Reversing the joystick axis


JBotAlan
02-09-2005, 07:22 PM
Sorry if I didn't search well enough, but how does one go about reversing the joystick value? I tried a negative, but I realized the pwm value is an unsigned val, what is the math I need to do on the joystick value to make it so foreward is backward and backward is foreward?

Tristan Lall
02-09-2005, 07:34 PM
#DEFINE PWM_MAX 254
...
pwm01 = PWM_MAX - p1_y //Your joystick 1 y-value is reversed

jgannon
02-09-2005, 07:34 PM
Sorry if I didn't search well enough, but how does one go about reversing the joystick value? I tried a negative, but I realized the pwm value is an unsigned val, what is the math I need to do on the joystick value to make it so foreward is backward and backward is foreward?
Instead of:
pwm01=p1_x;
do:
pwm01=255-p1_x;
Good luck.

pakrat
02-09-2005, 07:47 PM
Instead of:
pwm01=p1_x;
do:
pwm01=255-p1_x;
Good luck.


Yeah, this worked for us