Example Code

Random Array Element Selector in 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.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview:

This code allows the user to use a remainder in order to select a random array element.

 

Description:

The VI features taking in the current background color and averaging the contrasts of the red, blue and green fields to determine whether to use a dark or light font. The background flashes back and forth to random colors, adding a fun game show style to the atmosphere.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Enter in your desired Array Elements on the Front Panel
  2. Run the VI

Additional Information or References

4543.png

 

Additional Note:
If over a hundred array elements are added, you will need to change the multiplication factors of the random numbers to accommodate for this. The VI currently selects a random color and places this in the text box then switches back to the default color before doing so again. If the user wants to they can disable the case structure and only use random colors.

 

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

 

 

 


Thank You
Eric Reid
National Instruments
Motion R&D

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