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
|
#include "Wire.h"
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C LCD(0x27,16,2);
#include "iarduino_RTC.h"
iarduino_RTC watch (RTC_DS1302,5,7,6); // pour module DS1302
// iarduino_RTC watch (RTC_DS1307); // pour module DS1307 i2C
// iarduino_RTC watch (RTC_DS3231); // pour module DS3231 i2C
void setup() {
Serial.begin(9600);
LCD.init();
LCD.backlight();
watch.begin();
//integer zheur;
//zheur == "12";
int Heur = 0;
// 0 sec, 30 min, 18 hour, 2 date, january, 2022, wed
watch.settime(0, 00, 13, 3, 9, 22, 0);
}
void loop() {
// si 1 seconde s'est écoulée affiche l'heure
if (millis() % 1000 == 0) {
Serial.println(watch.gettime("d-m-Y, H:i:s, D"));
LCD.setCursor(0,0);
LCD.print(watch.gettime("d M Y, D"));
LCD.setCursor(0,1);
LCD.print(watch.gettime("H"));
char Heur = (watch.gettime("H"));
String Heura = String(Heur);
int Heurb = Heura.toInt();
if (Heurb >= 12) {
LCD.setCursor(0,2);
LCD.print("Apres-Midi");
}
else {
LCD.setCursor(0,2);
LCD.print("Matin");
}
}
} |
Partager