arduino-lcd-leds
arduino-lcd-leds
h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
void setup() {
// Initialisation du LCD
lcd.init();
lcd.backlight();
lcd.clear();
// Message initial
lcd.setCursor(0, 0);
lcd.print("Etat des LEDs:");
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
void updateLCD() {
lcd.setCursor(0, 1);
// Affiche l'état de chaque LED (● pour allumée, ○ pour éteinte)
lcd.print(led1State ? "1:" : "1:");
lcd.print(led1State ? "\x01" : "\x00");
lcd.print(" ");
lcd.print(led2State ? "2:" : "2:");
lcd.print(led2State ? "\x01" : "\x00");
lcd.print(" ");
lcd.print(led3State ? "3:" : "3:");
lcd.print(led3State ? "\x01" : "\x00");
lcd.print(" ");
lcd.print(led4State ? "4:" : "4:");
lcd.print(led4State ? "\x01" : "\x00");
}
void loop() {
// Mise à jour périodique du LCD
if (millis() - lastLCDUpdate >= LCD_UPDATE_INTERVAL) {
updateLCD();
lastLCDUpdate = millis();
}
if (!boutonActif) {
digitalWrite(led4, LOW);
led4State = false;
}
}
// Interruption du bouton
void boutonChange() {
boutonActif = (digitalRead(bouton) == LOW);
if (!boutonActif) {
digitalWrite(led4, LOW);
}
}