View Full Version : Button programming help
02-09-2010, 11:07 AM
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.
02-09-2010, 11:21 AM
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.
Joystick leftStick, rightStick;
// In teleop control:
drive.tankDrive(leftStick, rightStick); // Drive when trigger is pressed
drive.drive(0.0, 0.0); // Stop driving if trigger is released
02-10-2010, 08:59 AM
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.
02-17-2010, 12:01 PM
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-2018, Jelsoft Enterprises Ltd.