08-28-2021 03:51 PM
Hi guys,
I want to create a small Labview Vi that count up when I press a "+" button and then to count down if i press a "-"button.
For example if i press 10 times the + then the numeric indicator on the front window to show me number 10 and then if i press the - button to be able to count down from 10 at each press of the "-" button.
At the moment i can count up using the shift register of a while loop but i don't manage t0 get right the second part...to count down from where i stopped the count up
Thanks for your suggestion
08-28-2021 04:14 PM
I could not open the VI because it was in 2020 version. Anyway, your requirement is simple enough, you can avoid corner cases by using an event structure to capture the button presses and the typical shift register to maintain the count value, just a while loop and shift register will not work out well in this case.
08-28-2021 05:04 PM
Please start with the simple learning resources listed at the top of the forum.
You don't understand dataflow yet, but maybe try to execute your code using execution highlighting and you will see that the top loop runs once and stops, then the second loop runs once, then stops. All done! (I really hope you are not using the "run continuously" mode!).
Both of your buttons are outside the loop and only get read once.
All you need is a single while loop that continues to spin at a define rate and a single indicator that you can increment or decrement based on which button to press. The buttons belong inside the loop! The you need a stop button at the loop terminal to stop the program when you are done.
Since you are counting, there should be no orange, because you are only dealing with integers.
Se how far you get.
08-28-2021 05:15 PM
Maybe this very primitive code can give you a start (all buttons are latch action).
Once it works the way you want you can make the code a little more fancy by e.g. using an event structure and add other features.