During this segment I want to play the tone on repeat indefinitely with a slight pause between rings until the user presses the button. What I currently have works but has very small detection window where if you don't hold down the button it will miss it. How can I have it detect the button press without it being held in order to break from the loop. Thanks for any help!
case MODE_RINGING:
if (dButtonPressed == false) {
for (int thisNote = 0; thisNote < 10; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(4, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(4); }
delay(4000);
break;
}
else { break; }
}