View Single Post
  #7   Spotlight this post!  
Unread 02-02-2005, 23:17
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: need help w/ joystick code

Quote:
Originally Posted by willie837
I have a single joystick code for my robot, but I don't want it to do anything when i tilt the joystick left and right.
A single joystick with no left/right action will give you only one axis of control. At first glance, it looks like you're asking for a robot which will only go forward and backward, and never turn. The easiest way to do that is to replace every occurrence of p1_x in the user_routines.c file with the constant 127.

But that can't be what you want. Are you perhaps asking how to keep the robot from turning in place when you aren't also moving forward or backward? That's conceptually easy, and I could probably change the code myself to do it in about 30 seconds, but it's not easy to describe to a novice programmer. Try changing every occurrence of p1_x to the following:
Code:
(((p1_y<137)&&(p1_y>117))?127:p1_x)
Basically, this keeps the x-axis value at neutral when the y-axis value is within 10 of neutral.

Last edited by Alan Anderson : 02-02-2005 at 23:21.