Button programming help

My team is trying to program our joysticks to where the trigger button on a Logitech Attack 3 controller is used for throttle on our bot (like a throttle button on a video game) So if we hit the joystick and are not holding the trigger the bot won’t move. I was wondering if anybody has the code or can tell us how to write the code to do this, help would be apperciated. we are using tank drive. We are using Java to program our robot.

You can use the getTrigger() method on a Joystick to determine whether or not the button is being pressed. If it is, call the tankDrive() method, and if it isn’t, tell the robot to stop driving. This could be done by calling drive() with 0.0 as the speed and curve values.


// Assumptions: these are already set up and configured.
RobotDrive drive;
Joystick leftStick, rightStick;

// In teleop control: 
if (rightStick.getTrigger())
    drive.tankDrive(leftStick, rightStick);  // Drive when trigger is pressed
    drive.drive(0.0, 0.0);          // Stop driving if trigger is released

Yup, that’s about all you’d need. Just make sure you aren’t destroying the gearboxes by like going full speed and then hitting the trigger to stop movement instantaneously.

so would it be similar to do that with a pendulum style kicker. we are using springs and pistons to power to kicker