View Single Post
  #3   Spotlight this post!  
Unread 10-02-2007, 15:55
EOC's Avatar
EOC EOC is offline
Registered User
AKA: Eric Curry
None #1208 (Metool Brigade)
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Illinois
Posts: 200
EOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant future
Smile Re: Programming a Joystick

joystick related code is delt with in user_routines.c. Each button has it's own variable. Joystick positions have two variables, 1 for the x directions and one for the y directions. The values for these positions are mapped like pwm values: 0 is full one direction, 127 means the joystick is in it's neutral position, and 255 means the joystick is being pushed as far as it goes in the other direction. Because of the nature of the values, putting the line of code:

pwm01 = p1_y;

... would be legit, because when the joystick is just sitting there, it doesn't move, and when the joystick is pushed forward/backward all the way, the motor goes as fast as it goes in the appropriate direction. This setup is a bit twitchy, because slight movements in the joystick gets responses from the motor.

Variable names are in the format *joystick_port_name*_*button/axis*.
This means p2_x is the variable dealing with the joystick plugged into the second control port, and the has to do with the x axis directions.

As for unplugging the joystick in the middle of a competion; don't. It confuses the robot, and bad things happen .