Created
October 3, 2018 18:43
-
-
Save hinzundcode/1c094a630af627b8a8171eeb731aa973 to your computer and use it in GitHub Desktop.
puck js clock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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