Thread: my code
View Single Post
  #9   Spotlight this post!  
Unread 28-02-2011, 09:20
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: my code

Quote:
Originally Posted by Garten Haeska View Post
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);

}
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote