|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
joystick button
hey, i'm trying to program a motor to run off of a button on the joystick (preferably the trigger button) but i'm not sure exactly how to do that can someone help me?
|
|
#2
|
|||
|
|||
|
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
}
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. |
|
#3
|
||||
|
||||
|
Re: joystick button
yeah, i'm using labview, thanks though
|
|
#4
|
|||
|
|||
|
Re: joystick button
Break the problem down. First see if you can figure out how to read the joystick button.
Next use the Motor WPI VIs to set the motor speed to 0 or some nonzero value to control the speed. Now put the two together so that the button Boolean selects one of two speeds. If you want the button to be sticky, you need storage such as a feedback node, a shift register, or a variable. If this doesn't help, ask for specifics on the part above you can't figure out. Greg McKaskle |
|
#5
|
||||
|
||||
|
Re: joystick button
i'm sorry but i'm a rookie, and none of what you just said really made any sense
|
|
#6
|
|||
|
|||
|
Re: joystick button
Programming involves breaking big tasks down into small tasks that you know how to do. First figure out how to read a joystick button. You might want to look at examples, or show the context help window and look at the palette of icons for reading the joystick.
Then move on to the other steps. Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming a joystick button... | programmr | Programming | 2 | 05-01-2009 16:13 |
| Using a button on a joystick to track? | DemonYawgmoth | Programming | 5 | 12-02-2006 11:17 |
| Joystick Hat button | ten3brousone | Programming | 8 | 20-02-2005 13:31 |
| Joystick Button programming | Bharat Nain | Programming | 5 | 18-02-2005 11:48 |
| Joystick Button Deference | cibressus53 | Electrical | 3 | 01-11-2004 09:38 |