Example Code

How to make a 7 segments count from 0 to 9 and vice versa using LabVIEW and DAQmx for 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


  • NI DAQmx

Code and Documents



This program makes the 7 segments highlight which make it count from 0 to 9 and vice versa



This example uses a flat sequence structure which execute the codes written in it form left to right you can put a timer in each frame you can add frame by right clicking on its left side and press add frame after.


Steps to Implement or Execute Code

  1. put a while loop (make sure there is a control in th while loop (stop button ))
  2. creat a case structure with two cases ( 0 , default) and (1)
  3. in each case put a flat sequence structure
  4. add 9 more frames in each frame sequence in both cases
  5. before we continue coding we will begin wirring
  6. now you must connect one of the these terminals to the ground (H or C)
  7. connect the (F) with (dio 0) , (G) with (dio 1) , (I) with (dio 2) , (J) with (dio 3 ) , (E) with (dio 4) , (D) with (dio 5) ,(B) with (dio 6),(A) with (dio 7 )
  8. now you can connect the reisitor to the grond and connect the other terminal with (h or c ) or you can connect the terminals (from F to A ) doesn't conculed (H or C ) with resistors and connect them to thier terminals
  9. now we continue coding
  10. confige a ni my daq by putting a daq assisstant (make sure you connect your daq assisstant to your pc )
  11. click on genrate signal then digital output then port output and finaly click ok
  12. copy (control + c ) your configered daq assisstant in each frame
  13. put 10 true constants or fales ones doesn't matter in each frame , abuild array(2 in each frame ) ,and boolean array to number
  14. you can configer if you want false or true constant by clicking on it
  15. expande one of your build array in each frame to become 10 slots connect the 10 boolean constants to the build array
  16. after you have connect the boolean constants to build array connect the build array to the array to number function and then connect it to the other build array whitout expanding it and connect it to the daq assistant
  17. if the first boolean constant is true the (f) which is the middle segment will be lighted witch connected to the dio 0 and the reset are like that 
  18. so you must put true value in the specific part of it to be lighted as each terminal is responsable of a segment now you should (e) false always as it lights the little point in the right which is number 5 in the build array as we made our configration and wirring 
  19. now configer the o case wich is default case by puting true and false values by making the first frame lights the segments to put a zero and the last on sould be 9 and the second one sould be 1 and like that 
  20. now in the other case 1 we will make the first frame 9 and the last is 0 and of coure the second one will be 8 
  21. add a shift register by right clicking on the while loop and and click at add shift register connect it to the case structure  and then connect it to a select function you will see a three terminals in the first one you connect it to  a string constant and type in it (1) the secont connect it to a true constant and the thired on connect the shift registor to it make sure that the shift register passses through the case selector 
  22. now in the (1) case do the shift register like we did before but this time type (0) in the string constant 
  23. connect hte shift register to the end of it witch is a arrow up and but a constant in the shift register in the other terminal which has an arrow looking down make it 0 
  24. you can put a wait timer in esach frame because it will execute the code as fast as it can 
  25. then you are good to go
  26. if you any problem in wirring or writting codes you can  download the project and the photo with it 




Labview2012 (or compatible)


  1. NI MyDAQ
  2. 7 Segments LED
  3. Breadboard
  4. 330 Resistor

Additional Images
Block Diagram


 **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.