#include <Wire.h>
#include <LiquidCrystal.h>
#include<DS3231.h>
#include <Servo.h>
LiquidCrystal lcd(2, 3, 7, 6, 5, 4);
DS3231 rtc;
Servo servo1, servo2;
#define buz 11

int Hor;

int Min;

int Sec;
bool h12;
bool hPM;
int Mon;//month
int Date;
int Yr;
bool month;



void setup()

{ 
  servo1.attach(10);
  servo2.attach(9);
  Wire.begin();

  Serial.begin(9600);

  pinMode(buz, OUTPUT);

  lcd.begin(16,2);  

  lcd.setCursor(0,0);

  lcd.print("Hi! I am");
  lcd.setCursor(0,1);

  lcd.print("Medibot  :)");
  delay(1000);
//  h12=false;
  //hPM=false;
  // The following lines can be uncommented to set the date and time
 // rtc.setDoW(Friday);  // Set Day-of-Week to SUNDAY
  rtc.setHour(18);  // Set the time to 7(24hr format)
  rtc.setMinute(14);
  rtc.setSecond(40);
  rtc.setDate(29);// Set the date to January 1st, 2014
  rtc.setMonth(04);
  rtc.setYear(23);
  delay(2000);

}




void loop()

{

byte Hour = rtc.getHour(h12, hPM);

  Min = rtc.getMinute();

  Sec = rtc.getSecond();
  Date=rtc.getDate();
byte Mon=rtc.getMonth(month);
  Yr=rtc.getYear();
  lcd.setCursor(0,0);

  lcd.print("Time: ");
  lcd.print(Hour);
  lcd.print(":");
  lcd.print(Min);
  lcd.print(":");
  lcd.print(Sec);

 lcd.setCursor(0,1);

 lcd.print("Date: ");
  lcd.print(Date);
  lcd.print("/");
  lcd.print(Mon);
  lcd.print("/");
  lcd.print(Yr);


if( Hour == 18 && (Min == 15 && Sec == 00))
{
    servo1.writeMicroseconds(20000); // rotate
    delay(950);
   servo1.writeMicroseconds(15000);  // stop
    delay(500);
}



 //lcd.print();

 if( Hour == 18 && (Min == 15 || Min == 16)) //Comparing the current time with the Alarm time

{

Buzzer();

Buzzer();

lcd.clear();

lcd.print("Time for");

lcd.setCursor(0,1);

lcd.print("Medicine");

Buzzer();

Buzzer();

} 




if( Hour == 18 && (Min == 18 && Sec == 00))
{
    servo2.writeMicroseconds(20000); // rotate
    delay(950);
   servo2.writeMicroseconds(15000);  // stop
    delay(500);
}



 //lcd.print();

 if( Hour == 18 && (Min == 18 || Min == 19)) //Comparing the current time with the Alarm time

{

Buzzer();

Buzzer();

lcd.clear();

lcd.print("Time for");

lcd.setCursor(0,1);

lcd.print("Medicine");

Buzzer();

Buzzer();

} 

 delay(1000); 

}


void Buzzer()

{

digitalWrite(buz,HIGH);

delay(500);

digitalWrite(buz, LOW);

delay(500);

}
//   servo1.writeMicroseconds(20000); // rotate
//      delay(950);
  //    servo1.writeMicroseconds(15000);  // stop
    //  delay(500);
   //servo2.writeMicroseconds(2000); // rotate
     // delay(950);
     // servo2.writeMicroseconds(1500);  // stop
      //delay(500);
$abcdeabcde151015202530fghijfghij
GND5VSDASCLSQWRTCDS1307+