Quote:
Originally posted by cammie825
I know that everyone is in deep with their programs at this point, but I'm having problems programming a dead zone into our joysticks. When we put the program in, it seemed to not respond all the time. Like it would go backwards, and then it would decide that it wouldn't go backwards anymore. I'm not really sure. Here's what we put in:
Thanks!
|
The problem is, you're not giving the stop_p3_y function a chance to execute. Also, PBASIC doesn't allow multiple comparisons (117<p1_y<137).
The easiest way is to check how far away it is from the middle (127) and compare it with a zone value. Usually around 6-10 is a good DEAD_ZONE value.
Here's an example of the drive code I used on TOBOR V last year. We had a tank-style drivetrain.
Code:
Drive:
left_motor:
if (abs(p1_y - 127) > DEAD_ZONE) then right_motor
p1_y = MOTOR_OFF
right_motor:
if (abs(p3_y - 127) > DEAD_ZONE) then Drive_return
p3_y = MOTOR_OFF
Drive_return: