I am checking for pressing of a switch(negative logic) inside the condition of a while loop. But the variable in which I store the input button press does not change state if I press the button. If I keep pressing the switch and reset the Arduino board, the press is recognized.
I tried making the variable volatile but I don't understand why it still don't work? I also tried to read from register instead of digitalRead
but in vain.
volatile char ok_btn;
ok_btn= digitalRead(10);
while(ok_btn!=0)
{
Serial.println("ok button not pressed/n");
delay(200);
}
Serial.println("ok button pressed/n");
It seems the variable ok_btn
is just reading once and storing it for ever!