Ok merci, alors ce premier code c'est pour l'heure et le deuxième pour le menu et je voudrais savoir comment tu ferais pour les mélanger entre autre
#include <Wire.h>
#include <TimeLib.h>
#include "DS1307RTC.h"
#include <LiquidCrystal.h>
#include <Console.h>
const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
tmElements_t tm;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup(){
bool parse=false;
bool config=false;
// get the date and time the compiler was run
if (getDate(__DATE__) && getTime(__TIME__)) {
parse = true;
// and configure the RTC with this info
if (RTC.write(tm)) {
config = true;
}
}
{
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
lcd.begin(16, 2);
if (parse && config) {
Serial.print("DS1307 configured Time=");
Serial.print(__TIME__);
Serial.print(", Date=");
Serial.println(__DATE__);
} else if (parse) {
Serial.println("DS1307 Communication Error :-{");
Serial.println("Please check your circuitry");
} else {
Serial.print("Could not parse info from the compiler, Time=\"");
Serial.print(__TIME__);
Serial.print("\", Date=\"");
Serial.print(__DATE__);
Serial.println("\"");
}
}
}
void loop() {
tmElements_t tm;
if (RTC.read(tm)) {
print2digits(tm.Hour);
lcd.write(':');
print2digits(tm.Minute);
lcd.write(':');
print2digits(tm.Second);
lcd.print(' ');
lcd.print(' ');
lcd.print(' ');
print2digits(tm.Day);
lcd.write('/');
print2digits(tm.Month);
} else {
if (RTC.chipPresent()) {
lcd.println("The DS1307 is stopped. Please run the SetTime");
lcd.println("example to initialize the time and begin running.");
lcd.println(RTC.get());
} else {
lcd.println("DS1307 read error! Please check the circuitry.");
}
delay(9000);
}
lcd.setCursor(0, 0);
delay(1000);
}
bool getTime(const char *str)
{
int Hour, Min, Sec;
if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
tm.Hour = Hour;
tm.Minute = Min;
tm.Second = Sec;
return true;
}
bool getDate(const char *str)
{
char Month[12];
int Day, Year;
uint8_t monthIndex;
if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
for (monthIndex = 0; monthIndex < 12; monthIndex++) {
if (strcmp(Month, monthName[monthIndex]) == 0) break;
}
if (monthIndex >= 12) return false;
tm.Day = Day;
tm.Month = monthIndex + 1;
tm.Year = CalendarYrToTm(Year);
return true;
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
lcd.write('0');
}
lcd.print(number);
}