--- /dev/null
+import RPi.GPIO as GPIO
+from RPLCD.gpio import CharLCD
+import socket
+import fcntl
+import struct
+import time
+from signal import signal, SIGINT
+from sys import exit
+
+lcd = CharLCD(cols=20, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23], numbering_mode=GPIO.BOARD)
+lcd.clear()
+
+def handler(signal_received, frame):
+ lcd.close()
+ print('SIGINT or CTRL-C detected. Exiting gracefully')
+ exit(0)
+
+def get_ip_address(ifname):
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915,
+ struct.pack('256s', ifname[:15])
+ )[20:24])
+
+if __name__ == '__main__':
+ signal(SIGINT, handler)
+ while True:
+ for i in range(0,6):
+ lcd.clear()
+ lcd.write_string("Time: %s" %time.strftime("%H:%M:%S"))
+ lcd.cursor_pos = (1, 0)
+ lcd.write_string("Date: %s" %time.strftime("%m/%d/%Y"))
+ time.sleep(1)
+ lcd.clear()
+ lcd.write_string("IP Address:")
+ lcd.cursor_pos = (1, 0)
+ lcd.write_string(get_ip_address('eth0'))
+ time.sleep(5)
+
+#lcd.clear()
+#lcd.write_string(u'Hello world!')
+#lcd.crlf()
+#lcd.write_string(u'Hello world!')
+lcd.close()