import machine
import utime
import tm1637
# Initialize the display (CLK=16, DIO=17)
tm = tm1637.TM1637(clk=machine.Pin(16), dio=machine.Pin(17))
# Set brightness (0 to 7)
tm.brightness(3)
# Initialize the internal RTC
rtc = machine.RTC()
# Optional: Set the time manually (Year, Month, Day, Weekday, Hr, Min, Sec, Subsec)
# rtc.datetime((2023, 10, 27, 4, 12, 30, 0, 0))
while True:
# Get current time from RTC
t = rtc.datetime()
hours = t[4]
minutes = t[5]
seconds = t[6]
# Display hours and minutes
# The 'True' argument toggles the colon (:)
# We blink the colon every second using the parity of seconds
show_colon = seconds % 2 == 0
tm.numbers(hours, minutes, show_colon)
utime.sleep(0.5)