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); + } }