I borrowed Sheepdogguides interrupt program and caused the interrupt to print the date and time to the Serial monitor – Yes I know one should not print within interrupts!
A compile error appeared “class RTC_DS1307” has no member named “begin”.
Serendipitously I tried including “include <wire.h>” and that fixed the compile error.
Now why should the RTC need to have the Wire library included?
Code: Select all
#include "RTClib.h"
RTC_DS1307 RTC;
#define TEMP_PIN 2 //See Note 1, sheepdogguides..ar3ne1tt.htm
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN 3 // the pin for button
volatile byte burp=0; // a counter to see how many times the pin has changed
byte cmd=0; // a place to put our serial data
void setup() {
digitalWrite(TEMP_PIN, LOW);
pinMode(TEMP_PIN, INPUT); // sets the digital pin as input (logic 1)
Serial.begin(9600);
RTC.begin();
delay(100);
Serial.print("PinChangeInt test on pin ");
Serial.print(PIN);
Serial.println();
pinMode(PIN, INPUT); //set the pin to input
digitalWrite(PIN, HIGH); //use the internal pullup resistor
PCintPort::attachInterrupt(PIN, burpcount,FALLING); // attach a PinChange Interrupt to our pin on the rising edge
// (RISING, FALLING and CHANGE all work with this library)
// and execute the function burpcount when that pin changes
RTC.adjust(DateTime(__DATE__, __TIME__));
}
void loop(){
}
void burpcount()
{
burp++;
Serial.print("burpcount:\t"); //\t means a tabular space.
Serial.println(burp, DEC);
interrupts();
DateTime now = RTC.now();
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(3000);
}