I am doing an experiment. In this experiment I want to start the RTC by presing the external Push Button which is connected with Aquino's pin 2 and take varites of action according to Time. For interrupt I have made a ISR and in this interrupt I wrote my main logic. But this things is not working.
The schematics is
and The code is
`include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 9);
RTC_DS1307 rtc;
int k = 0;
int led =13;
int pin =2;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
lcd.begin(16, 2);
rtc.begin();
Serial.begin(11520);
pinMode(led,OUTPUT);
pinMode(pin,INPUT);
attachInterrupt(0, Time , LOW);
// Print a message to the LCD.
if (! rtc.begin()) {
lcd.print("hello, world!");
while (1);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
}
}
void loop()
{}
void Time()
{
{DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print(now.year(), DEC);
lcd.print("/");
lcd.print(now.month(), DEC);
lcd.print("/");
lcd.print(now.day(), DEC);
lcd.print(" ");
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
int c = now.second();
lcd.setCursor(0, 1);
lcd.print(c);
if(c==58)
{
k=k+1;
lcd.setCursor(5, 1);
lcd.print(k);
if(k==4)
{
digitalWrite(led,HIGH);
k=0;
}
}
}}`
please help me.