Hello everyone,
So, I was trying out a new code I found online at Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System. I keep getting an error message. I followed all the instructions on that website on how to wire the Arduino up, so the hardware is not an issue. The code is:
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since 1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.unixtime() + 7 * 86400L + 30);
Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}
Since I took the code from adafruit's website, I'm assuming the code is right.
But each time I try to run this code, I get the following error message:
sketch_mar08a:6: error: 'RTC_DS1307' does not name a type
I have read other posts where people faced similar problems and the suggested solution was to install the library in the right place. I have read more about installing libraries on the adafruit learning system website and I think that my RTC library is in the right place (it is in the folder 'libraries' in the folder 'Arduino' in Documents). So, I'm not sure what I'm doing wrong here. I was wondering if any one can help?
Thank you!