Skip to content

Instantly share code, notes, and snippets.

@sourceperl
Created February 26, 2016 15:51
Show Gist options
  • Save sourceperl/778a5f3cba2a3a05a7ec to your computer and use it in GitHub Desktop.
Save sourceperl/778a5f3cba2a3a05a7ec to your computer and use it in GitHub Desktop.
Clock on a Rpi with a 4x20 LCD on I2C port
#!/usr/bin/env python3
import time
import schedule
import RPi_I2C_LCD
# global var
lcd = RPi_I2C_LCD.LCD()
def update_lcd():
# l2
lcd.set_cursor(row=1)
lcd.message(time.strftime('%d/%m/%Y %H:%M:%S', time.localtime()))
if __name__ == '__main__':
# init LCD screen
lcd.set_backlight(True)
lcd.home()
schedule.every(1).second.do(update_lcd)
# main loop
while True:
schedule.run_pending()
time.sleep(.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment