Code for a physical binary clock with an Arduino, an LED dot matrix, and an RTC module.
#include "LedControl.h" | |
#include <DS3231.h> | |
// Initialize the dot matrix and the clock | |
LedControl lc = LedControl(7, 5, 6, 1); | |
DS3231 clock; | |
void setup() { | |
// Start up and clear the matrix | |
lc.shutdown(0, false); | |
lc.setIntensity(0, 1); | |
lc.clearDisplay(0); | |
// Start the clock and set its time to the sketch compiling time | |
clock.begin(); | |
clock.setDateTime(__DATE__, __TIME__); | |
} | |
void loop() { | |
RTCDateTime dt = clock.getDateTime(); | |
lc.setColumn(0, 1, (dt.hour / 10) << 2); // Tens digit of hour | |
lc.setColumn(0, 2, (dt.hour % 10) << 2); // Ones digit of hour | |
lc.setColumn(0, 3, (dt.minute / 10) << 2); // Tens digit of minute | |
lc.setColumn(0, 4, (dt.minute % 10) << 2); // Ones digit of minute | |
lc.setColumn(0, 5, (dt.second / 10) << 2); // Tens digit of second | |
lc.setColumn(0, 6, (dt.second % 10) << 2); // Ones digit of second | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.