Saturday, April 27, 2013
GPi clock in Python
Now I am writing a Python program to display time in Guzunty Pi LED driver. The first thing is to get the digits to display.
# *** Get digits representing hour, minute, and second - tlfong01 2013apr27 ***
import time
timeString = time.asctime( time.localtime(time.time()) )
print timeString
print "Hour digit 1 = ", timeString[11:12]
print "Hour digit 2 = ", timeString[12:13]
print "Minute digit 1 = ", timeString[14:15]
print "Minute digit 2 = ", timeString[15:16]
print "Second digit 1 = ", timeString[17:18]
print "Second digit 2 = ", timeString[18:19]
# Sample output
# Sat Apr 27 14:36:22 2013
# Hour digit 1 = 1
# Hour digit 2 = 4
# Minute digit 1 = 3
# Minute digit 2 = 6
# Second digit 1 = 2
# Second digit 2 = 2
# .END
No comments:
Post a Comment