IntervalTimer interruptTimer;
IntervalTimer interruptTimer2;
const int BUZZER = 14; // set the pin here...
volatile int buzzC = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600); // USB
while (!Serial && millis() <= 3000) if (!(millis() % 500)) ;
Serial.println("Hello World! ... ");
// buzzer works here!
interruptLoop();
delay(1000);
interruptLoop();
delay(1000);
interruptLoop();
delay(1000);
interruptLoop();
delay(2000);
interruptTimer.begin(interruptLoop, 2000000);
interruptTimer2.begin(interruptLoop2, 250000);
// interruptTimer.priority(250);
}
void loop() {
}
void interruptLoop() {
tone(BUZZER, 100, 1000);
delay(500);
Serial.print("\nyes,this loop is triggered by the interrupt too...");
Serial.println(buzzC);
buzzC = 0;
}
void interruptLoop2() {
digitalWriteFast(LED_BUILTIN, 0 );
buzzC++;
delay(175); // Remove this to complete the one second buzzer, Smaller delay is lo0nger tone is longer
Serial.print("...:");
Serial.print(buzzC);
digitalWriteFast(LED_BUILTIN, 1 );
}