#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
RTC_DS1307 rtc;
//////////Current Time
int h=0;
int m=0;
int s=0;
//////////Start time
int h1=0;
int m1=0;
int s1=0;
/////////Stop time
int h2=0;
int m2=0;
int s2=0;
int st = 0 ;
void setup() {
rtc.begin();
Serial.begin(115200);
lcd.init();
lcd.backlight();
}
void loop() {
time();
void loop() {
// Obtener la hora actual del RTC
RTCDateTime now = rtc.getDateTime();
// Verificar si es la hora deseada (por ejemplo, 15:30:00)
if (now.hour == 15 && now.minute == 30 && now.second == 0) {
// Realizar la tarea deseada aquí
Serial.println("Ejecutar tarea a las 15:30:00");
// Puedes agregar más lógica aquí según tu tarea
}
/* lcd.setCursor(0,0);
lcd.print(String(h)+" :"+String(m)+" :"+String(s)+" ");
*/
//end loop
void time() {
DateTime now = rtc.now();
int sw1=digitalRead(4);
delay(100);
if(sw1==0){
st++;
if (st>=7) {
st=0;
}
}
h = now.hour();
m = now.minute();
s = now.second();
///////////////////HR
lcd.setCursor(0,0);
lcd.print("Time");
lcd.setCursor(6,0);
if (h <= 9 ){
lcd.print("0");
}
lcd.print(h);
lcd.setCursor(8,0);
lcd.print(":");
//////////////Min
lcd.setCursor(9,0);
if (m <= 9 ){
lcd.print("0");
}
lcd.print(m);
lcd.setCursor(11,0);
lcd.print(":");
///////////////Sec
lcd.setCursor(12,0);
if (s <= 9 ){
lcd.print("0");
}
lcd.print(s);
}