Example Code

LED Sequence in CVI

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

  • Other

Code and Documents

Attachment

Download All

Overview

This example demonstrates creating a LED sequence in LabWindows/CVI.

 

Description

This example has 3 sequences and runs them repeatedly. The first sequences moves through each LED, turning it on. The second sequence moves through each LED, turning it off. The third sequences alternates between two LED patterns. Control arrays are used to set which LEDs are controlled in each sequence. A timer is used to step through each sequence. The speed of the sequence can be controlled by the user. The color is also changeable. This example can be expanded to control actual LEDs using serial communication with a microcontroller or an Arduino, for example.

 

Requirements

Software

  • LabWindows/CVI 2012 (or compatible)  

 

Steps to Implement or Execute Code

  1. Create the user interface and specify control arrays for LEDs that you would like to control as a group. In this example there are 3 control arrays.
  2. Create sequences that determine which LEDs you want to turn on or off by accessing the control array and setting the values to 1 for on or 0 for off.
  3. Create a timer that will switch between the sequences with a certain time delay.
  4. With a list box, let users select the color of the LED. Change the On Color attribute of the LEDs appropriately.
  5. With a numeric knob, let users change the speed of the sequences. Change the Timer Interval attribute appropriately.

 

Additional Information or References

User Interface

1.jpg

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

Jaime Peña
National Instruments Mexico
Ingeniería de Aplicaciones
www.ni.com/soporte

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