This statement makes a sound
foo...
tone(HO8, hertz);
bar...
this one does not:
foo...
tone(HO8, hertz);
if (target == 2) tone(AM7, hertz);
bar...
HO8 is 2 speakers and a horn, thru the obligatory resistor. AM7 is that same horn, through an amplifier. Why in world does that never make a tone? Regardless of target value. I comment out the second line and it works fine, but not for my purposes down road...
Here is the function:
void beep(int flag, int targetSet) {
int i;
// Beep II Function
/*
if (hookedUp == 0) {
noTone(A0);
noTone(A1);
return;
}
*/
if (flag == -1) {
noTone(A0);
noTone(A1);
eventSound = "";
eventName = "";
} //STOP
if (flag == 0) {
//Check if need to continue
if (millis() - beepMS > beepLen) {
noTone(A0);
noTone(A1);
i = iBeep;
i = i + 1;
targetSet = target; //Keep Target same
flag = 1;
}
}
// Continue
if (flag == 1) {
target = targetSet;
if (eventName != "") {
eventSound = eventName;
}
noTone(A0);
noTone(A1);
for (i; i < beepArrSize; i++) {
if (eventSound == aEventName[i]) {
iBeep = i;
beepLen = aBeepLen[i];
hertz = aBeepHertz[i];
beepMS = millis();
Serial.print("BeepLen: ");
Serial.println(beepLen);
Serial.print("Hertz:");
Serial.println(hertz);
tone(HO8, hertz);
if (target == 2) tone(HO8, hertz); //For some reason this prevents beeps
i = 100;
}
}
}
}