Thread: joystick button
View Single Post
  #2   Spotlight this post!  
Unread 07-02-2009, 13:52
bwobo bwobo is offline
Team 1458
FRC #1458
Team Role: Engineer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: California
Posts: 15
bwobo is just really nicebwobo is just really nicebwobo is just really nicebwobo is just really nice
Send a message via AIM to bwobo
Re: joystick button

If you look in the SimpleRobot example class it shows a joystick defined:
Code:
Joystick *joystickname;
//then later:
joystickname = new Joystick (1) //where "1" is, is the USB port on the Driver Station in which the joystick is plugged into.
//then in your teleop code:
if (joystickname -> GetRawButton(button #)){
//put code here for which motor to run
}
Of course this is with WindRiver and C++, LabView you will need someone else's help on

EDIT:
Saw your other thread.
This code will make it so when you hold a button down the specified motor runs.
If you want it so one button sends it forward, and another backward, its the same thing, just another if statement. (in one if statement, set the motor to a value of 1 (makes it go forward full speed), then in the other if statement, set the motor to a value of -1 (full speed in reverse)
If you want it so you only have to press the button once for it to start, then again for it to stop, you need to create a boolean for the motor running, and have the button set it true or false.
__________________

Last edited by bwobo : 07-02-2009 at 13:56.