hamzaa
March 9, 2010, 10:10am
1
Hey guys,
I am using the following code to wait for a button press to start,
while(true){
if (digitalRead(BUTTON_PIN) == LOW)
break;
But sometimes I have to press the button multiple times for arduino to detect press sometimes it works with one press, am I missing something?
Button is on the prototyping board(JC1) by default it is high.
system
March 9, 2010, 10:14am
2
Did you set BUTTON_PIN as INPUT?
do:
while (digitalRead(BUTTON_PIN));
hamzaa
March 9, 2010, 10:29am
3
yeap BUTTON_PIN is set as INPUT.
while (digitalRead(BUTTON_PIN));
that solved the issue..
Thanks.
How about:
while(digitalRead(BUTTON_PIN) == LOW){}
Basically, while the button is not pressed, do nothing (nothing inside the brackets)
Mowcius
system
March 9, 2010, 1:06pm
5
How about posting your full code? This way we can get a better idea of what your trying to accomplish. It just seams like your trying to over complicate this.