#include <Wire.h>
#include <LiquidCrystal.h>
#include <time.h>
#include <DS3232RTC.h>
#include <TimeAlarms.h>
#include <EEPROM.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup() {
pinMode(10, OUTPUT);
lcd.begin (16, 2);
lcd.clear();
lcd.setCursor(0, 0);
setSyncProvider(RTC.get);
if (timeStatus() != timeSet)
lcd.print("Unable to sync with the RTC");
else
lcd.print("RTC Ready With");
lcd.setCursor(5,1);
lcd.print("TIME");
delay(1500);
lcd.clear();
// Set the alaram times to go off
Alarm.alarmRepeat(07, 24, 0, A);
Alarm.alarmRepeat(07, 25, 0, B);
Alarm.alarmRepeat(13, 28, 0, C);
Alarm.alarmRepeat(13, 29, 0, D);
Alarm.alarmRepeat(13, 30, 0, E);
Alarm.alarmRepeat(13, 51, 0, G);
Alarm.alarmRepeat(13, 52, 0, H);
Alarm.alarmRepeat(13, 50, 0, I);
}
void loop() {
digitalClockDisplay(); //Display the data
Alarm.delay(1000); // wait one second between clock display
}
// Display the time and date
void digitalClockDisplay() {
lcd.setCursor(3, 0);
printDigits(day());
lcd.print(day());
lcd.print("/");
printDigits(month());
lcd.print(month());
lcd.print("/");
lcd.print(year());
lcd.setCursor(4, 1);
printDigits(hour());
lcd.print(hour());
lcd.print(":");
printDigits(minute());
lcd.print(minute());
lcd.print(":");
printDigits(second());
lcd.print(second());
}
void printDigits(int digits) {
if (digits < 10)
lcd.print('0');
}
void A() {
digitalWrite(10, HIGH); // turn the relay on (HIGH is the voltage level)
Alarm.delay(4000); // wait for Sound bell for 4 seconds
digitalWrite(10, LOW); // turn the relay off by making the voltage LOW
}
void B() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void C() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void D() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void E() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void G() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void H() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
void I() {
digitalWrite(10, HIGH);
Alarm.delay(4000);
digitalWrite(10, LOW);
}
I have total 8 alarm to go but only 6 alarms are working