Skip to content

Instantly share code, notes, and snippets.

@eddieespinal
Created January 14, 2015 19:02
Show Gist options
  • Select an option

  • Save eddieespinal/97d8a60de433565269c1 to your computer and use it in GitHub Desktop.

Select an option

Save eddieespinal/97d8a60de433565269c1 to your computer and use it in GitHub Desktop.
Display Date/Time on an LCD with Electric Imp
// 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