From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying a number from 0 to 180 on a 7-segment LED

I want to display a number from 0 to 180 on a 7-segment LED. My thinking was to receive the number as a string and then break it into 3 subarrays (one for each digit) and then display the digits accordingly. But I am not sure if this will work as not all numbers have three digits. Can someone please help me and show me how to do resolve this issue? (which is breaking up the number "string" and separate it into 3 digits "characters")?  

 

Thank you

0 Kudos
Message 1 of 3
(2,241 Views)

Will this be on three 7-segment displays?

 

You can check how many digits a number has based on log base 10 of the number.  (Though sometimes there could be round off errors in floating point calculations that throw that off.  I had a calculation in a database once that was always correct, except when it was acting on the number 1000.  I had to write an exception for that.)

 

You could convert the number to a string using %d, and count how many characters are in the string.

 

Or you could use %03d.  That will give you leading zeroes.  Then when you go to display, you replace any leading zero with a 7-segment array where all segments are off.

 

Or use %3d, and it pads the leading spots with spaces.  Then you just replace spaces with an all-off pattern when displaying.

 

 

0 Kudos
Message 2 of 3
(2,226 Views)

There are a few examples of LabVIEW creating 7 segment displays. 

 

Here is a thread to get you started:  https://forums.ni.com/t5/LabVIEW/7-segment-LED/td-p/902065

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 3 of 3
(2,205 Views)