I'm not using any external time source. Not even the Processing SyncArduinoClock, yet.
The code I'm using is the following but I'm sure there is a more efficient way to simply display time on the LED. There are many examples using RTCs and it's library but I couldn't find any using setTime in conjunction with the LED/Backpack. Eventually I intend to display time and temperature using the MPL3115A2 and log the data to a SD card shield. But that will be later.
Thanks in advance.
Chris
Here's the code:
Code: Select all
#include <Time.h>
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_7segment matrix;
time_t t;
tmElements_t tm;
int seconds, minutes, hours;
void setup()
{
matrix.begin(0x70);
matrix.setBrightness(0);
tm.Second = 0;
tm.Minute = 51;
tm.Hour = 23;
tm.Day = 26;
tm.Month = 11;
tm.Year = CalendarYrToTm(2014);
t = makeTime(tm);
}
void loop(void)
{
minutes = minute(t);
hours = hour(t);
matrix.writeDigitNum(0, (hours / 10) % 10, false);
matrix.writeDigitNum(1, (hours % 10), false);
matrix.drawColon(true);
matrix.writeDigitNum(3, (minutes / 10) % 10, false);
matrix.writeDigitNum(4, minutes % 10, false);
matrix.writeDisplay();
++t;
delay(1000);
}