Quote:
Originally Posted by Garten Haeska
i do need help though i want to stop my arm when it hits a limit switch, now ive searched CD and cant quite figure it out, but when it is triggered i want my arm to stop and when it is not triggered i want my arm to drive. How might i go about doing this. btw. this would replace the timer reference in my autonomy. Please help!!!! 
|
I'm not 100% on what you mean, but if you want your arm to move only while the trigger is being held, you'd have to use a conditional, an essential in any programming language.
Code:
public void operatorControl() {
if(joystick.getTrigger()) {
// move the arm based on the joystick's Y-axis
arm.set(joystick.getY());
} else {
/* stop the arm if the trigger isn't held down
* useful note: the arm will remain in it's position
* until you move it again. this simply stops the arm
* from moving, not sets it back down in
* it's starting position. you can code this easily.
*/
arm.set(0.0);
}
/* just for reference, you would still be able
to drive if the trigger is not held down. */
robotDrive.drive(joystick);
}