View Single Post
  #1   Spotlight this post!  
Unread 12-03-2012, 22:20
KeyFalcon KeyFalcon is offline
Registered User
FRC #4185 (Fanastic Falcons)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Fairfield
Posts: 5
KeyFalcon is an unknown quantity at this point
Joystick Trigger and Button C++ Programming

Hello. I am on a Rookie team and I am a Rookie programmer. I have no idea how to program the buttons on the joystick. I just need help programming the buttons for our robot's shooter motor and intake motor. Any help would be appreciated.

Thank you!
Code:
/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */ 
class RobotDemo : public SimpleRobot
{
	Victor (victora);
	Victor (victorb);
	Victor (victorc);
	Victor (victord);
	RobotDrive myRobot; // robot drive system
    Joystick rightstick;
    
 public:
	RobotDemo(void):
		victora (1),
		victorb (2),
		victorc (3),
		victord (4),
		myRobot(victora,victorb,victorc,victord),	// these must be initialized in the same order
		rightstick(2)		// as they are declared above.
	    
	{
		myRobot.SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		myRobot.SetSafetyEnabled(false);
		myRobot.Drive(0.0, 0.5); 	// drive forwards half speed
		Wait(10.0); 				//    for 2 seconds
		myRobot.Drive(0.0, 0.0); 	// stop robot
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		myRobot.SetSafetyEnabled(true);
		while (IsOperatorControl())
		{
			myRobot.ArcadeDrive(rightstick); // drive with arcade style (use right stick)
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote