#include #include #define NUM_LEDS 1 ChainableLED leds(D4, D5, NUM_LEDS); enum LedState { OFF, FAST_RED, SLOW_RED, SLOW_GREEN }; LedState currentState = OFF; unsigned long previousMillis = 0; int blinkInterval = 0; bool ledOn = false; void updateLed() { unsigned long currentMillis = millis(); if (currentState == OFF) { leds.setColorRGB(0, 0, 0, 0); // Éteindre la LED return; } if (currentMillis - previousMillis >= blinkInterval) { previousMillis = currentMillis; ledOn = !ledOn; // Alterner entre ON et OFF switch (currentState) { case FAST_RED: leds.setColorRGB(0, ledOn ? 255 : 0, 0, 0); blinkInterval = 200; // Alternance rapide break; case SLOW_RED: leds.setColorRGB(0, ledOn ? 255 : 0, 0, 0); blinkInterval = ledOn ? 200 : 1300; // Court allumage, longue extinction break; case SLOW_GREEN: leds.setColorRGB(0, 0, ledOn ? 255 : 0, 0); blinkInterval = ledOn ? 200 : 1800; // Court allumage, longue extinction break; default: break; } } } void blinkFastRed() { currentState = FAST_RED; blinkInterval = 200; } void blinkSlowRed() { currentState = SLOW_RED; blinkInterval = 200; // Premier allumage court } void blinkSlowGreen() { currentState = SLOW_GREEN; blinkInterval = 200; // Premier allumage court } void clearLed() { currentState = OFF; leds.setColorRGB(0, 0, 0, 0); }