03-24-2013 11:31 PM
Any help would greatly be appreciated. Note: I have tried many things I have come across online for hours... I did try to find a solution myself.
Solved! Go to Solution.
03-25-2013 12:24 AM
I just built a VI to do this with the FRC team I mentor; unfortunately, that code is on a team laptop and I don't have it. The idea is you use a while loop with an uninitialized shift register. The shift register maintains the previous state of the button. Each time you call the VI, you check if the previous button state was false and the current state is true, meaning the user just pushed the joystick button. If so, do whatever you needed to do. If you make this into its own VI and use it in several locations, make sure you set the VI to be re-entrant (VI properties, Execution category) otherwise it won't work as you expect.
The image below shows a very simple version that does only what you want. We made ours more complex with a reset input and an additional output so that it could toggle (press once to turn on, press again to turn off).
03-25-2013 12:30 AM
I have modified and attached a VI snippet that may be useful.
also could refer to this URL
03-25-2013 05:17 PM
Hi JJay
I will recommend you to use an event structure that way your code will only be executed one time per event on the front panel. Here are a link with more information about the Event Structure and a example.
Regards.
Esteban R.
03-25-2013 05:21 PM
Esteban.R wrote:
I will recommend you to use an event structure that way your code will only be executed one time per event on the front panel. Here are a link with more information about the Event Structure and a example.
This is definitely not an option. First, LabVIEW provides no way to trigger events on joystick buttons (at least that I've ever seen). Second, the VIs shown in the screenshot are from the FIRST Robotics toolkit, although there's no way to know that unless you've worked with an FRC team. The robotics code runs on a cRIO, which doesn't support user interface events.