Guys, I have question regarding void setup as in sample below. when i program an arduino, it directly executes void loop without completing the conditions below. anything wrong with my code?
probably spin is not >= 5 so you don't enter the while loop... but as you did not post the full code and how things are declared or wired (PULLUP ?), we have no clue..may be you meant
void setup () {
while (spin < 5) { // **** changed to <
pbstate = digitalRead(7);
if (pbstate != lbstate) {
if (pbstate == LOW)
spin++;
else
delay(100);
lbstate = pbstate;
}
digitalWrite(9, HIGH);
}
}
thank you for your reply. code also does not execute digitalWrite (9,HIGH);. pbstate is = to a switch installed on PIN7. i have not pressed the switch still it proceeds to the void loop.