Skip to content

Instantly share code, notes, and snippets.

@TwoTau
Created August 6, 2018 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TwoTau/f8e2eea346d02420e46a1f94e01c8d87 to your computer and use it in GitHub Desktop.
Save TwoTau/f8e2eea346d02420e46a1f94e01c8d87 to your computer and use it in GitHub Desktop.
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);
}
@TwoTau
Copy link
Author

TwoTau commented Aug 6, 2018

arduino-binary-clock-wiring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment