02-03-2021 03:13 PM
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:
Solved! Go to Solution.
02-03-2021 03:21 PM
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.
02-03-2021 08:15 PM
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.