#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd (0x27, 16, 2);
RTC_DS3231 RTC;
Servo servo;
int H = 1;
int M = 21;
int S = 00;
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
Serial.begin(9600);
RTC.begin();
servo.attach(8);
servo.write(0);
RTC.adjust(DateTime(__DATE__,__TIME__));
}
void loop() {
lcd.clear();
DateTime now = RTC.now();
if((H == now.hour() && M == now.minute() && S == now.second()) || digitalRead(7) == 1){
lcd.setCursor(0, 0);
lcd.print("Sirviendo");
lcd.setCursor(0, 1);
lcd.print("Comida");
lcd.display();
servo.write(90);
delay(1300);
servo.write(0);
delay(200);
}
else{
servo.write(0);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Hora:");
lcd.println(now.hour());
lcd.println(":");
lcd.println(now.minute());
lcd.println(":");
lcd.println(now.second());
lcd.setCursor(0, 1);
lcd.println("Pgm:");
lcd.println(H);
lcd.println(":");
lcd.println(M);
lcd.println(":");
lcd.println(S);
lcd.display();
}
}