Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
puck js clock
function update() {
var now = new Date();
var minutes = now.getMinutes();
if (minutes < 10)
minutes = "0"+minutes;
var seconds = now.getSeconds();
if (seconds < 10)
seconds = "0"+seconds;
var time = now.getHours()+":"+minutes+":"+seconds;
g.clear();
g.drawString(time, 0, 0);
g.flip();
}
I2C1.setup({ scl: D1, sda: D2 });
var g = require("SSD1306").connect(I2C1, function () {
g.setFontVector(20);
update();
setInterval(update, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment