#!/usr/bin/python # OH3NWQ 2017 # example using a character LCD connected to a Raspberry Pi Zero W import time from time import gmtime, localtime, strftime import Adafruit_CharLCD as LCD import subprocess import os # Your wiring is propbably different # I got D4 and D5 lines crossed so corrected them in code lcd_rs = 26 lcd_en = 19 lcd_d4 = 6 lcd_d5 = 13 lcd_d6 = 5 lcd_d7 = 11 lcd_backlight = 4 lcd_columns = 20 lcd_rows = 4 # Initialize the LCD using the pins above. lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) # Print a four line banner lcd.message('Raspberry Pi Zero W\n OH3NWQ \n Vesa Tervo \n 2017') # Show banner for 2 seconds time.sleep(2) lcd.clear() while True: nowl = strftime("%Y-%m-%d %H:%M:%S", localtime()) nowz = strftime("%Z", localtime()) nowup = subprocess.check_output("uptime | sed s/.*up/up/ | sed s/,\ \ [0-9]\ user.*/\ \ \ \ \ / | sed s/\ \ /\ /", shell=True) nowload = subprocess.check_output("uptime | sed s/.*rage:\ //", shell=True) lcd.home() lcd.message('Time is now ('+nowz+'):\n'+nowl+'\n'+nowup+nowload.rstrip()) #refresh every 2 seconds time.sleep(2)