1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| // Intervals de clignotement LED
const unsigned long BLINK_JAUNE = 350;
const unsigned long BLINK_ROUGE = 350;
const unsigned long BLINK_BLEUE = 350;
const unsigned long BLINK_VERTE = 350;
const int LED_JAUNE = 7;
const int LED_ROUGE = 6;
const int LED_BLEUE = 5;
const int LED_VERTE = 4;
// Précédent état de la LED
byte etatJaune = LOW;
byte etatRouge = LOW;
byte etatBleue = LOW;
byte etatVerte = LOW;
void setup() {
pinMode (LED_JAUNE, OUTPUT);
pinMode (LED_ROUGE, OUTPUT);
pinMode (LED_BLEUE, OUTPUT);
pinMode (LED_VERTE, OUTPUT);
digitalWrite(LED_JAUNE, LOW);
digitalWrite(LED_ROUGE, LOW);
digitalWrite(LED_BLEUE, LOW);
digitalWrite(LED_VERTE, LOW);
}
void loop() {
ledJaune();
ledRouge();
ledBleue();
ledVerte();
}
void ledJaune(){
static unsigned long previousMillisJaune = 0;
static byte etatJaune = LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousMillisJaune >= BLINK_JAUNE) {
previousMillisJaune = currentMillis;
etatJaune = !etatJaune;
digitalWrite(LED_JAUNE, etatJaune);
}
}
void ledRouge(){
static unsigned long previousMillisRouge = 0;
static byte etatRouge = LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousMillisRouge >= BLINK_ROUGE) {
previousMillisRouge = currentMillis;
etatRouge = !etatRouge;
digitalWrite(LED_ROUGE, etatRouge);
}
}
void ledBleue(){
static unsigned long previousMillisBleue = 0;
static byte etatBleue = LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousMillisBleue >= BLINK_BLEUE) {
previousMillisBleue = currentMillis;
etatBleue = !etatBleue;
digitalWrite(LED_BLEUE, etatBleue);
}
}
void ledVerte(){
static unsigned long previousMillisVerte = 0;
static byte etatVerte = LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousMillisVerte >= BLINK_VERTE) {
previousMillisVerte = currentMillis;
etatVerte = !etatVerte;
digitalWrite(LED_VERTE, etatVerte);
}
} |
Partager