I have a fairly complex program which is running OK, and in which I have several "do loops."
However I have run into a problem in using one in a particular place.
I wish to have certain functions performed at power turn-on.
Therefore I have included a switch, which will ground Pin 5 if pressed at turn-on, and the following code just after setup{
delay(50);
pinMode( 5, INPUT);
H = digitalRead(5);
/////////// below doesn't work /////////////////
while ( H == 0 ) {
delay(50); // just wait until switch is released
}
// Nor does this:
do{
delay(50);
} while ( H == 0 );
/////////////////////////////////////////////////
This hardware pin is shared with the LCD Display "enable" function, and after the above code I initialize the display and all works well from there on. (The display is inoperable during the initial turn-on, as it is initialized only after the initial switch test. )
A test on H later (after display initialization) shows that H follows the switch on/off correctly. However, I would like to have the program wait until the switch is released before proceeding, and I haven't figured out how to do that.
I don't understand why a simple "while" statement won't work. Any suggestions?