//Libraries
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal_I2C.h>
//Connections and constants
LiquidCrystal_I2C lcd(0x27,16,2);
RTC_DS1307 rtc;
char daysOfTheWeek[7][12]= {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int btSet = A0;
const int btAdj = A1;
const int btAlarm = A2;
//Variables
int DD,MM,YY,H,M,S,set_state,adjust_state,alarm_state,AH,AM,shake_state;
String alarm = " ";
//Boolean flags
boolean setupScreen = false ;
boolean alarmOn = false ;
void setup() {
// init RTC and LCD library items
rtc.begin();
lcd.begin(16,2);
//Set outputs/inputs
pinMode(btSet, INPUT_PULLUP);
pinMode (btAdj, INPUT_PULLUP);
pinMode (btAlarm, INPUT_PULLUP);
Serial.begin(9600);
Serial.print("System Ready");
lcd.backlight();
//Check if RTC has a valid time/date, if not set it to 00:00:00 01/01/2018.
//this will run only at first time or if the coin battery is low.
if (!rtc.isrunning()){
Serial.println("RTC in NOT running");
//This line sets the RTC with an explicit date & time, for example to set
//January 1,2018 at 00:00am you would call:
rtc.adjust(DateTime(2018,01,01.00,00,00));
}
delay(100);
}
void loop() {
}
void readBtns(){
set_state = digitalRead(btSet);
adjust_state = digitalRead(btAdj);
alarm_state = digitalRead(btAlarm);
if(!setupScreen){
if(alarm_state == LOW){
if(alarmOn){
alarm =" ";
alarmOn = false;
}
else{
alarmOn = true ;
}
delay(500)
}
}
}