LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

resetting a counter in while loop

Solved!
Go to solution

Hi, I am doing a little counter program that counts a number that is greater than 0.5 generated by a random number generater. I am able to stop the program once the count hits let's say 10 using a while loop. however, I do not want to stop the whole program, I want to be able to stop the count once it hits 10 and then press a button to reset it back to 0. I tried using another while loop inside the while loop but the program won't even stop once I pressed the stop button. How should I go about implementing a reset count button? and what loops should I use to pause the counting without stopping the whole program?

I will attach the part of the code that is working:

0 Kudos
Message 1 of 3
(1,247 Views)

When your counting, it is a good idea to use integers rather than floating point numbers.

 

IF you want to return to the beginning, the quickest way is to just wrap another While loop around what you have now.

0 Kudos
Message 2 of 3
(1,244 Views)
Solution
Accepted by topic author Derrick2407

You basically have a state machine with a few states (idle, counting, resetting, etc.). So all you need in one loop and a case structure.

 

One simple draft is attached, see if it can give you some ideas.

0 Kudos
Message 3 of 3
(1,199 Views)