Use Joystick Button to Toggle Between Cases Using LabVIEW for FRC

Updated Oct 23, 2023

Reported In

Hardware

  • roboRIO
  • roboRIO-FRC

Software

  • LabVIEW
  • FRC Software
  • LabVIEW roboRIO Software Suite

Issue Details

I am using LabVIEW to program my FIRST Robotics Competition robot using a NI roboRIO:
  • I want to use my joystick to toggle between two cases. I have two different behaviors I want to switch based on a boolean button click.
  • I am programming a toggle between two drivetrains (for example: arcade and mecanum) for my robot.

Solution

  1. You can use a One-Shot button press to make sure you capture when the driver clicks the button in the joystick and you process it once, regardless of the amount of time it was clicked: [FRC 2015] Making a One-Shot Button Press
  2. You can use a combination of case structure and shift register to make sure you switch the status every time you get a TRUE from your One-Shot button press: Joystick Button where the Boolean Remains True Snippet
  3. You can implement your two states in two different cases inside one case structure.

Additional Information

Find below an example on how to use this functionality:
 
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, download the image from attachments, save it to your computer in the same file format, and drag the file onto your LabVIEW diagram.