I got an error where it says date is not declared in this scope. My friend runs the exact same code and it works for him. Anyone got any idea?
#include <Wire.h>
#include "RTClib.h" // Credit: Adafruit
RTC_DS1307 RTC;
void setup() {
// Begin the Serial connection
Serial.begin(9600);
// Instantiate the RTC
Wire.begin();
RTC.begin();
// Check if the RTC is running.
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running");
}
// This section grabs the current datetime and compares it to
// the compilation time. If necessary, the RTC is updated.
DateTime now = RTC.now();
DateTime compiled = DateTime(__DATE, TIME__);
if (now.unixtime() < compiled.unixtime()) {
Serial.println("RTC is older than compile time! Updating");
RTC.adjust(DateTime(__DATE, TIME__));
}
Serial.println("Setup complete.");
}
void loop() {
// Get the current time
DateTime now = RTC.now();
// Display the current time
Serial.print("Current time: ");
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();
delay(10000);
}