View Full Version : Button programming help
interplanetary
09-02-2010, 12:07
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.
Example:
// 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
else
drive.drive(0.0, 0.0); // Stop driving if trigger is released
joshholat
10-02-2010, 09:59
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.
chris janney
17-02-2010, 13:01
so would it be similar to do that with a pendulum style kicker. we are using springs and pistons to power to kicker
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.