Oh, and here's the code in case anyone would like to see how to talk to a Betabrite LED sign, or use the Time library:
// Betabrite Countdown
// Counts down the time until Maker Faire Bay Area 2012
// Uses Betabrite 1040 display, Arduino, and ChronoDot
#include <Time.h> // Time Library
#include <Wire.h> // Wire for RTC
#include <DS1307RTC.h> // DS3231/ChronoDot works like DS1307
time_t MFBA; // Start time of Maker Faire
time_t difftime; // difference between current and target time
int diff_seconds;
int diff_minutes;
int diff_hours;
int diff_days;
// Initialize RTC and Betabrite sign
void setup() {
Serial.begin(9600); // set baud to 9600
UCSR0C = (2<<UPM00)|(0<<USBS0)|(2<<UCSZ00)|(0<<UCPOL0); // configure for 7E1 not 8N1
setSyncProvider(RTC.get); // set sync to use the ChronoDot
setSyncInterval(10); // sync every 10 seconds if possible
// check whether sync worked
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
tmElements_t MFBA_elements; // elements array to construct Maker Faire start time
// 10:00 AM on May 19th, 2012
MFBA_elements.Second = 0;
MFBA_elements.Minute = 0;
MFBA_elements.Hour = 10;
MFBA_elements.Wday = 7;
MFBA_elements.Day = 19;
MFBA_elements.Month = 5;
MFBA_elements.Year = 2012 - 1970;
MFBA = makeTime(MFBA_elements); // Unix timestamp of Maker Faire start time
// Initialize Betabrite memory locations
for(int i = 0; i < 5; i++) Serial.write((byte)0x00); // auto detect baud
Serial.write((byte)0x01); // SOH
Serial.print("Z00"); // All displays
Serial.write((byte)0x02); // STX
Serial.print("E$AAU0100FF001BL00C00000"); // Set mem locations for text and string
Serial.write((byte)0x04); // ETX
delay(1000);
// Initialize text file
// String "1" will be called whenever scrolling animation restarts
for(int i = 0; i < 5; i++) Serial.write((byte)0x00); // auto detect baud
Serial.write((byte)0x01); // SOH
Serial.print("Z00"); // All displays
Serial.write((byte)0x02); // STX
Serial.print("AA"); // Text string
Serial.write((byte)0x1B); // ESC
Serial.write((byte)0x20); // Line number
Serial.print("a"); // Scroll right to left
Serial.write((byte)0x10);
Serial.print("1 until Maker Faire"); // Call string 1 plus text
Serial.write((byte)0x04); // ETX
}
time_t systime; // holds current time for diff calculation
void loop() {
if (systime != now()) { // wait for new second to do anything
systime = now();
difftime = MFBA - systime; // subtract current time from Maker Faire time
diff_seconds = difftime % 60; // get seconds
difftime /= 60; // convert to minutes
diff_minutes = difftime % 60; // get minutes
difftime /= 60; // convert to hours
diff_hours = difftime % 24; // get hours
difftime /= 24; // convert to days
diff_days = difftime; // get days
// Update string on Betabrite with updated countdown
for(int i = 0; i < 5; i++) Serial.write((byte)0x00); // auto baud rate
Serial.write((byte)0x01); // SOH
Serial.print("Z00"); // All displays
Serial.write((byte)0x02); // STX
Serial.print("G1"); // Write to string 1
digitalClockDisplay(); // Send countdown string
Serial.write((byte)0x04); // ETX
}
}
// modified routine from Time Library example
void digitalClockDisplay(){
Serial.print(diff_days);
Serial.print(" Days ");
printDigits(diff_hours);
Serial.print(" Hours ");
printDigits(diff_minutes);
Serial.print(" Minutes ");
printDigits(diff_seconds);
Serial.print(" Seconds");
}
// routine from Time Library example
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
//Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}