From b9be9b84ea6626e30a77e89a10f1bf1ed5fe04be Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Sat, 8 Nov 2025 12:02:28 +0100 Subject: [PATCH] use blink for display --- the-cup.ino | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/the-cup.ino b/the-cup.ino index 4b7cf62..33018ba 100644 --- a/the-cup.ino +++ b/the-cup.ino @@ -119,18 +119,19 @@ void byte_to_string(byte array[], unsigned int len, char buffer[]) { } void displayError() { - for (unsigned int i = 0; i < 6; i++) - { - digitalWrite(LED_PIN, HIGH); - delay(600); - digitalWrite(LED_PIN, LOW); - delay(300); - } + blink(6, 300); } void displaySuccess() { - digitalWrite(LED_PIN, HIGH); - delay(1000); - digitalWrite(LED_PIN, LOW); - delay(300); + blink(1, 1000); +} + +void blink(unsigned int times, unsigned int duration) { + for (unsigned int i = 0; i < times; i++) + { + digitalWrite(LED_PIN, HIGH); + delay(duration); + digitalWrite(LED_PIN, LOW); + delay(duration); + } }