#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <Buzzer.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
RTC_DS1307 RTC;
DateTime now;
#define buzzerPin 11
int Hor;
int Min;
int Sec;
String myTime;
void setup()
{
Wire.begin();
RTC.begin();
Serial.begin(9600);
//pinMode(buz, OUTPUT);
pinMode(buzzerPin, OUTPUT);
//tone(buzzerPin, 1000, 2000);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("DIYHacking.com");
lcd.setCursor(0,1);
lcd.print("Arduino Alarm ");
// The following lines can be uncommented to set the date and time
//rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014
delay(2000);
}
void loop()
{
DateTime now = RTC.now();
Hor = (now.hour());
Min = (now.minute());
Sec = (now.second());
myTime = myTime + Hor +":"+ Min +":" + Sec ;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Time: ");
lcd.print(myTime);
lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(now.minute(), DEC);
myTime = "";
delay(1000);
//Comparing the current time with the Alarm time
//if( Hor == 7 && (Min == 14 || Min == 20))
if( Min ==52)
{
//Buzzer();
//Buzzer();
lcd.clear();
lcd.print("Alarm ON");
lcd.setCursor(0,1);
lcd.print("Alarming");
delay(500);
tone(buzzerPin, 494); // B4
delay(500);
tone(buzzerPin, 600); // C4
delay(500);
/*
analogWrite(buz,200);
delay(500);
analogWrite(buz,100);
delay(500)
*/
//Buzzer();
}
}
/*
Buzzer();
}
}
void Buzzer()
{
digitalWrite(buz,HIGH);
delay(500);
digitalWrite(buz, LOW);
delay(500);
}*/