Pages: 1 2 [3]   Go Down
Author Topic: Help with Loops and IFs??  (Read 1081 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
Karma: 28
Posts: 2037
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"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.

Long Island, NY
Offline Offline
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

while(digitalRead(somePin) == LOW)

Queens, New York
Online Online
Faraday Member
Karma: 65
Posts: 2930
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: 1 2 [3]   Go Up
Jump to: