from machine import Pin, Timer
import time
class Clock:
def __init__(self, hours, minutes, seconds):
self.hours = hours
self.minutes = minutes
self.seconds = seconds
def addSecond(self):
if self.seconds == 59:
self.seconds = 0
self.minutes = self.minutes + 1
else:
self.seconds = self.seconds + 1
if self.minutes == 60:
self.minutes = 0
self.hours = self.hours + 1
if self.hours == 24:
self.hours = 0
h = int(input('HH: '))
m = int(input('MM: '))
s = int(input('SS: '))
clock = Clock(h, m, s)
tim = Timer(-1)
tim.init(period=1000, mode=Timer.PERIODIC, callback=lambda t:clock.addSecond())
while(1):
print('%02d:%02d:%02d' % (clock.hours, clock.minutes, clock.seconds))
time.sleep_ms(1000)