Example Code

Understanding the Various Types of Mechanical Actions for Boolean Controls in a Timed Loop Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • LabVIEW

Code and Documents



This VI helps to understand how the various mechanical action of booleans works when applied to buttons in a timed loop.



This simple VI shows directly how various the various mechanical actions for boolean controls (buttons) work when put inside a loop. For ease of use, each type of mechanical action is mapped to two buttons - one for a mouse click and another mapped to a function (F1, F2, etc.) key. The loop timing can also be controlled to see its influence on the behavior of certain mechanical actions.


Boolean buttons and controls can be configured to have any of six different types of mechanical action: Switch When Pressed, Switch When Released, Switch Until Release, Latch When Pressed, Latch When Release, Latch Until Release. This can be done by right-clicking the button and selecting the proper Mechanical Action. There is a small pictogram on how each mechanical action affects the behavior of the control, but it can be easier to understand how each action works by simply putting them in a loop.


This VI implements each action and maps them to two buttons - one for a mouse click and one for a function key. By running the VI, you will be able to more easily understand how each mechanical action works in a loop, and how changing the loop timing affects certain mechanical actions.



  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Run the VI.
  2. Press the various function keys or click the various buttons.
  3. Change the loop timing and repeat step 2. (Notice the change in the "Latch" actions.)


Additional Information or References VI Block Diagram

VI Snippet



**This document has been updated to meet the current required format for the NI Code Exchange.**




Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.


xavvvv, this is great, but the VI might be clearer if an output boolean was added to make clear exactly when the value for each indicator is output from the indicator.  See attached suggestion image.booleansuggestion.jpg