// déclare les broches
const int LED1 = 0;
const int LED2 = 1;
// miniseconde entre changement d'état
const unsigned int LED_INTERVAL_1 = 1000;
const unsigned int LED_INTERVAL_2 = 250;
// Précedente valleur de millis() LED 1 & 2
unsigned long previousMillisLED1 = 0;
unsigned long previousMillisLED2 = 0;
// Précédent état LED 1 & 2
byte etatBrocheLED1 = LOW;
byte etatBrocheLED2 = LOW;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
digitalWrite(LED1, etatBrocheLED1);
digitalWrite(LED2, etatBrocheLED2);
}
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillisLED1 >= LED_INTERVAL_1){
previousMillisLED1 = currentMillis;
etatBrocheLED1 = !etatBrocheLED1;
digitalWrite(LED1, etatBrocheLED1);
}
if(currentMillis - previousMillisLED2 >= LED_INTERVAL_2){
previousMillisLED2 = currentMillis;
etatBrocheLED2 = !etatBrocheLED2;
digitalWrite(LED2, etatBrocheLED2);
}
}