Log in

View Full Version : Reversing the joystick axis


JBotAlan
09-02-2005, 19:22
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
09-02-2005, 19:34
#DEFINE PWM_MAX 254
...
pwm01 = PWM_MAX - p1_y //Your joystick 1 y-value is reversed

jgannon
09-02-2005, 19:34
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
09-02-2005, 19:47
Instead of:
pwm01=p1_x;
do:
pwm01=255-p1_x;
Good luck.


Yeah, this worked for us