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
|
#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();
time.begin();
// 0 sec, 30 min, 18 hour, 2 date, january, 2022, wed
time.settime(0, 30, 18, 2, 1, 22, 0);
}
void loop() {
// si 1 seconde s'est écoulée affiche l'heure
if (millis() % 1000 == 0) {
Serial.println(time.gettime("d-m-Y, H:i:s, D"));
LCD.setCursor(0,0);
LCD.print(time.gettime("d M Y, D"));
LCD.setCursor(4,1);
LCD.print(time.gettime("H:i:s"));
}
} |
Partager