Pages: 1 2 [3]   Go Down
Author Topic: Help with Loops and IFs??  (Read 1104 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 29
Posts: 2047
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.
Logged

Long Island, NY
Offline Offline
Newbie
*
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?

Code:
while(digitalRead(somePin) == LOW)
{
   keepDoingThis();
}
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2944
"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.
Logged

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: