Sorry. I should have put this in my first post. It's the RTC test sketch provided by Adafruit on their website.
I have gone through many of the learning lessons from various places on the internet and I also have had good success with printing to screen with a couple of the lessons. Also, I have written a sketch that runs my coop door open and closed just great. I encountered lots of trouble trying to program lengthy pause times. So I decided that an RTC was needed to overcome millis() limitations.
Here is the RTC test sketch provided by Adafruit . . .
// 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);
}
I may be having trouble with my addition of the RTClib library. I remember reading somewhere in the gazillion pages of my studies that the Arduino IDE will automatically color the #include commands when the correct files are located in the library directory. My IDE colors those commands blue and I'm pretty sure that's not good. I did have some difficulty getting those RTClib.cpp and RTClib.h files in the library. I might have something wrong there. But when I compiled that sketch no error messages were given. Hmmmmm.
Here is the sketch that I have tried to use with the lengthy pause intervals between run times for my door motor. I have tested this same sketch with much shorter timing settings and it works very good.
// Drive motor CW 34 seconds, pause 16 hours, run motor CCW 34 seconds, pause 8 hours, repeat. L.C. H. 2/24/2013
// Motor A definitions
int DIR_A = 12;
int SPEED_A = 3;
int BREAK_A = 9;
// Motor B definitions
int DIR_B = 13;
int SPEED_B = 11;
int BREAK_B = 8;
void setup()
{
pinMode(SPEED_A, OUTPUT);
pinMode(DIR_A, OUTPUT);
pinMode(BREAK_A, OUTPUT);
// release break
digitalWrite(BREAK_A, LOW);
}
void loop()
{
// run motor backward full speed. (Max is 250)
digitalWrite(DIR_A, HIGH);
analogWrite(SPEED_A, 250);
// run motor for 34 seconds to open
delay(34000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door open 16 hours (minus runtime)
delay(57566000);
// run motor forward full speed. (Max is 250)
digitalWrite(DIR_A, LOW);
analogWrite(SPEED_A, 250);
// run motor for 34 seconds to close
delay(34000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door closed 8 hour (minus runtime)
delay(10000);
}