View Single Post
  #2   Spotlight this post!  
Unread 09-02-2010, 12:21
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Button programming help

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:
Code:
// 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
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote