|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Assigning Joystick Buttons?
New programmers here! We have some code written, but we don't know how to assign joystick buttons to code. Like, how would we assign a relay or a motor to, say, button 2 on our Joystick? Which VI do we edit to assign the buttons?
Thank you! -The Rookies |
|
#2
|
|||||
|
|||||
|
Re: Assigning Joystick Buttons?
to pick the button use Joystick Get Values and Index Array.
There is an example here: http://www.chiefdelphi.com/forums/at...7&d=1421930245 What you do with the button to control the motor or relay can be a Case structure, a Select, or some other decision making vi. Last edited by Mark McLeod : 27-01-2015 at 23:05. |
|
#3
|
||||
|
||||
|
Re: Assigning Joystick Buttons?
that's very helpful, thank you. but how do we connect the buttons to, say, a relay or motor or something? do we have to drag out a selector or something from the comparison tab?
|
|
#4
|
|||||
|
|||||
|
Re: Assigning Joystick Buttons?
What do you want to happen when button 1 is pushed?
For instance, operate as long as the button is held and stop when the button is released? Run a motor forward, backward, stop, half speed/full speed? A Relay can be any of these conditions: off/forward/reverse/on. What do you want the button to do? Last edited by Mark McLeod : 29-01-2015 at 14:52. |
|
#5
|
||||
|
||||
|
Re: Assigning Joystick Buttons?
We are using mecanum drive, and we want to rotate the robot using buttons 4 and 5 on the joystick (3 and 4 in the code, right?) Also, we want 2 window motors attached to spike relays to rotate forwards and lift our arm up while button 2 on the joystick is being pressed, and set the arm back down by reversing the motors with button 3.
Last edited by Team3220 : 29-01-2015 at 17:20. |
|
#6
|
|||||
|
|||||
|
Re: Assigning Joystick Buttons?
Something like this?
|
|
#7
|
||||
|
||||
|
Re: Assigning Joystick Buttons?
That is very helpful, thanks. What exactly do those selectors do/tell the computer to do?
|
|
#8
|
||||
|
||||
|
Re: Assigning Joystick Buttons?
Those selectors take the boolean input that is given by a button press (True for pressed, False for not) and act accordingly. For example, in Mark's example (on the right), a press button 1 on Joystick 0 sets the relay to forward when pressed and off when not; similarly, press on button 2 on the same joystick sets the relay to reverse. You can also use a case structure for joystick buttons (and I actually prefer these). These work the same way; by taking the boolean input and executing the appropriate process according to it's value.
|
|
#9
|
||||
|
||||
|
Re: Assigning Joystick Buttons?
That makes sense. Thanks a lot- it's "mentors" like you guys that make FRC fun.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|