10-03-2019 08:24 AM
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
10-03-2019 08:35 AM - edited 10-03-2019 08:36 AM
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.
10-03-2019 08:46 AM
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