I have two buttons that when pressed individually start its counterpart led display, that part works great. Yet I want to pause the led displays when both buttons are pressed, until a single button is pressed later. Right now when I let go of the two buttons, whichever was let go slightly later will start counting down. Here is the pertinent code:
detects if both buttons are held down:
else if(button1==1 && button2==1){ //if both buttons are held down the hold variable becomes 3 and both clocks stop
delay(5000);
hold=3;
}
keeps the loop there (paused) until a single button is pressed:
while(hold == 3){
button1 = digitalRead(inPin1); // read the input pin for button 1
button2 = digitalRead(inPin2); // read the input pin for button 2
if(button1 == 1){
hold = 1;
break;
}
else if(button2 == 1){
hold = 2;
break;
}
}
The first block of code I pasted sets hold to 3 if both buttons are held down. Once hold==3 the code remains in the while loop (second block of code I pasted) until either button is pressed. Hold becomes either 1 or 2 depending on the button that is pushed, at which time the code breaks out of the while loop and back into the normal loop structure where it can run one of the displays.
Whatever the logic you implement, I think you will need to do some "debouncing" of the button. See this note: http://arduino.cc/en/Tutorial/Debounce for a brief tutorial.