#include <stdio.h>
#include <LiquidCrystal_I2C.h>
#define CHAINE_MAX_CHAR 80
const int VITESSE_UART = 9600;
const char MSG_VOLUME[] = "Le volume est a";
const char MSG_TEMPERATURE[] = ", la temperature est de";
const char MSG_PROGRAMME[] = "Le programme roule depuis";
const char MSG_JOURS[] = "jour(s),";
LiquidCrystal_I2C ecranLCD(0x27, 16, 2);
void setup() {
ecranLCD.begin(20, 4);
Serial.begin(VITESSE_UART);
Serial.print("Cours sur la fonction sprintf()\n\n");
/* int volume = 4;
int temperature = 17;
char uneChaine[CHAINE_MAX_CHAR];
sprintf(uneChaine, "%s %d%s %dc\n", MSG_VOLUME, volume, MSG_TEMPERATURE, temperature);
Serial.print(uneChaine);
*/
}
void loop() {
char uneChaine2[CHAINE_MAX_CHAR];
int nbJours = 2, nbHeures = 9, nbMinutes = 5, nbSecondes = ((millis()/100) % 60);
sprintf(uneChaine2, "%s %d %s %02d:%02d:%02d\n", MSG_PROGRAMME, nbJours, MSG_JOURS, nbHeures, nbMinutes, nbSecondes);
Serial.print(uneChaine2);
delay(1000);
}