From 3872ece37be9018ae6290b929c94d54fa841ed77 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sun, 9 Oct 2022 14:40:33 +0200 Subject: [PATCH] Join ISRs --- metronom.ino | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/metronom.ino b/metronom.ino index d16f522..fa8a1db 100644 --- a/metronom.ino +++ b/metronom.ino @@ -25,21 +25,17 @@ void setup() { initButton(); ITimer.attachInterruptInterval_MS(10, TimerHandler); - ISR_Timer.setInterval(PERIOD_MS, metronomeBeat); - ISR_Timer.setInterval(PERIOD_MS, metronomeCountdown); + ISR_Timer.setInterval(PERIOD_MS, metronomeRun); } -void metronomeCountdown() { +void metronomeRun() { if (countdown > 0) { countdown -= 1; digitalWrite(BUTTON_LED_PIN, countdown % 2 ? HIGH : LOW); + } else if (countdown == 0) { + //tone(BUZZER_PIN, 1000, 100); } } -void metronomeBeat() { - if (countdown == 0) - tone(BUZZER_PIN, 1000, 100); -} - void loop() {}