Go Down

Topic: Help with Loops and IFs?? (Read 5177 times) previous topic - next topic


"Haha. Well that kind of stinks.... There's got to be a way to do it, no? smiley-sad

I need the program to get to a certain point where it gets stuck in a loop waiting for an input to go HIGH. Once it goes HIGH I would like it to fall through to the rest of the code."

This is wrong thinking in arduino-world.    You don't want the program to get stuck in a loop in your code.  The loop() function cycles indefinitely to do this,  anyway.   If you want to "wait for something",   you exit from the loop() function  and then it will restart from the top,  to check your condition again.


Sorry to beat a dead horse, but I have a followup question.

In the following code, once the input goes HIGH and thus continues on to the rest of the program while the pin continue to be monitored or only when the program/compiler sees that line again?

Code: [Select]
while(digitalRead(somePin) == LOW)


It will only loop if the condition is true. If the condition is false, then it will get out of the loop.
My GitHub:

Go Up