This is a simple code which can probably be done a better way. The problem I am having is after some time the LED quites blinking, can anyone tell me why or maybe a better way to do this. The led is just to let me know the clock is working as it blink once per minute. Thanks
#include <Wire.h>
#include "RTClib.h"
#define clockAlarm 5 // Relay Output
#define ledIndicator 7 // LED Output
int hour1;
int minute1;
int year1;
int month1;
int day1;
int second1;
int runOnce = 0;
int ledEarlier =0;
RTC_DS1307 RTC;
void setup ()
{
Wire.begin();
RTC.begin();
pinMode (clockAlarm, OUTPUT); // set output 5
pinMode ( ledIndicator, OUTPUT); // set output 7
}
void loop () {
DateTime now = RTC.now();
hour1 = (now.hour());
minute1 = (now.minute());
second1 = (now.second());
if (now.minute() > ledEarlier)
{
ledEarlier = now.minute();
digitalWrite(ledIndicator, HIGH); // turn on led
delay(100);
digitalWrite(ledIndicator, LOW); // turn off led
}
else if (hour1 == 6 && minute1 == 55)
{
if(runOnce == 0)
{
digitalWrite(clockAlarm, HIGH); // activate alarm relay
delay(3000);
digitalWrite(clockAlarm, LOW); // activate alarm relay
runOnce = 1;
}
}
else
{
runOnce = 0;
}
delay(1000);
}