![]() |
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? :confused: Thank you! -The Rookies
|
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. |
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?
|
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? |
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.
|
Re: Assigning Joystick Buttons?
1 Attachment(s)
Something like this?
|
Re: Assigning Joystick Buttons?
That is very helpful, thanks. What exactly do those selectors do/tell the computer to do?
|
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.
|
Re: Assigning Joystick Buttons?
That makes sense. Thanks a lot- it's "mentors" like you guys that make FRC fun.
|
| All times are GMT -5. The time now is 08:50. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi