Example Code

Count Button Presses

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.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

A very simple example for showing how to keep count of the number of times a button is pressed using event Structure.

 

 

Description

A simple while loop with an event structure.  If the event is a timeout, Count is not increased.  If the event is a button press, increment Count. The steps are shown below:

1. Initialize the shift register to 0 to reset the counter each new run
2. Increment the count when the user presses the button
3. If the user didn't press the button, pass the count as it is
4. Update the count value on the front panel

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code

Download and run the VI "Count Button Presses_LV2012_NI Verified"

 

 

Additional Information or References

BD.PNG

 

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

Eric B.
National Instruments

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