#include <LiquidCrystal_I2C.h>
#define POT A0
#define MIN_POTENT 0
#define MAX_POTENT 1023
#define MIN_CONVERTI 0
#define MAX_CONVERTI 10
#define LCD_ADRESSE_I2C 0x27
#define LCD_NB_COLONNE 20
#define LCD_NB_LIGNE 4
#define BOUTON 2
LiquidCrystal_I2C ecranLCD(LCD_ADRESSE_I2C, LCD_NB_COLONNE, LCD_NB_LIGNE);
void setup() {
pinMode(BOUTON, INPUT);
ecranLCD.begin(LCD_NB_COLONNE, LCD_NB_LIGNE);
ecranLCD.print("Bonjours 420!");
delay(2000);
ecranLCD.clear();
}
void loop() {
byte etatBouton = digitalRead(BOUTON);
while(etatBouton == 1)
{
ecranLCD.backlight();
}
int valeurDuPotentiometre = analogRead(POT);
int volume = map(valeurDuPotentiometre,
MIN_POTENT, MAX_POTENT,
MIN_CONVERTI, MAX_CONVERTI);
ecranLCD.setCursor(1 , 0);
ecranLCD.print("Valeur du pot: ");
ecranLCD.print(valeurDuPotentiometre);
ecranLCD.print(" ");
ecranLCD.setCursor(1 , 1);
ecranLCD.print("Volume: ");
ecranLCD.print(volume);
ecranLCD.print(" ");
}