I have a while loop running, with delays and tones. Its condition is controlled by 5 inputs that are scripted above it. How do I run both at the same time?
More details: I am using an Uno. The 5 inputs are from a dtmf decoder. They are analog inputs if you were wondering about the critical level integer. What the dtmf part comes out to is 11 being the DTMFread if * is pressed.
if (analogRead(STQ) > criticallevel){
DTMFread = 0;
if (analogRead(Q1 > criticallevel){
DTMFread = DTMFread + 1;
}
if (analogRead(Q2 > criticallevel){
DTMFread = DTMFread + 2;
}if (analogRead(Q3 > criticallevel){
DTMFread = DTMFread + 4;
}if (analogRead(Q4 > criticallevel){
DTMFread = DTMFread + 8;
}
}
while (DTMFread != 11){
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_G4,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_C6,400);
delay(100);
tone(spkr,NOTE_C6,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_G4,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_B3,400);
delay(100);
tone(spkr,NOTE_A3,400);
delay(100);
tone(spkr,NOTE_G4,400);
delay(2100);
}
Below what is shown I have the if statement for DMTFread being 11. What I am trying to do is have both parts of the script running at once. Currently the tone prevents the DTMFread integer from changing.