Created
January 14, 2015 19:02
-
-
Save eddieespinal/97d8a60de433565269c1 to your computer and use it in GitHub Desktop.
Display Date/Time on an LCD with Electric Imp
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
| // create an ImpLcd instance. Our LCD is connected to I2C on ports 8,9 with a base address of 0x27 | |
| lcd <- ImpLcd(hardware.i2c89, 0x27, 2, 0); | |
| function updateClock() | |
| { | |
| local t = date(); | |
| // move to the first row, first column | |
| lcd.setCursor(0, 0); | |
| lcd.writeString(format("%02d:%02d:%02d", t.hour, t.min, t.sec)); | |
| // move to the second row, first column | |
| lcd.setCursor(0, 1); | |
| lcd.writeString(format("%02d-%02d-%04d", t.day, t.month, t.year)); | |
| // update the clock again in 1 second | |
| imp.wakeup(1, updateClock); | |
| } | |
| // fire updateClock() for the first time | |
| updateClock(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment