|Getting out of an open loop
|Page 1 of 1|
|Author:||hmgi [ Tue Jul 30, 2013 12:46 pm ]|
|Post subject:||Getting out of an open loop|
I need to be able to push a button to exit my lines of code so the cycle below will stop. Can anyone help me with this?
|Author:||Ernest3.14 [ Tue Jul 30, 2013 8:12 pm ]|
|Post subject:||Re: Getting out of an open loop|
Make a new variable, `bButtonPressed`. In each iteration of your loop, check for a button press. If one happens, set `bButtonPressed` to `true`. Then, change the conditional of your while loop to this: `(motorCount<1000) || (bButtonPressed==true)`. This will end the while loop if either `motorCount` goes above 1000 or if the button is pressed.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group