From b9035d04731c67ac68debed61c7b46615c6c75de Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 30 Apr 2021 08:09:38 +0200 Subject: [PATCH] Blink expected button on error --- super_simon/include/utils.h | 1 + super_simon/src/utils.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/super_simon/include/utils.h b/super_simon/include/utils.h index e36ac35..d6893b1 100644 --- a/super_simon/include/utils.h +++ b/super_simon/include/utils.h @@ -15,5 +15,6 @@ byte waitForButton(); void error(); void endGame(LiquidCrystal lcd, bool win, byte score); void configure(); +void blink(byte index); #endif //SUPER_SIMON_UTILS_H diff --git a/super_simon/src/utils.cpp b/super_simon/src/utils.cpp index abc87fc..3e530fa 100644 --- a/super_simon/src/utils.cpp +++ b/super_simon/src/utils.cpp @@ -65,6 +65,7 @@ bool userSequence(const byte sequence[], byte upTo) { } else { error(); + blink(expectedButton); return false; } } @@ -97,4 +98,13 @@ void endGame(LiquidCrystal lcd, bool win, byte score) { lcd.setCursor(0, 1); lcd.print(score); delay(10000); -} \ No newline at end of file +} + +void blink(byte index) { + for (byte i = 0; i < 3; i++) { + digitalWrite(LEDS[index], HIGH); + delay(100); + digitalWrite(LEDS[index], LOW); + delay(100); + } +}