from machine import Pin, SPI, I2C
from utime import sleep
from max7219 import Matrix8x8
import max7219
from tm1637 import TM1637
from ds1307 import DS1307
import time


i2c = I2C(0, scl=Pin(9), sda=Pin(8))
rtc = DS1307(i2c)
tm = TM1637(clk=Pin(6), dio=Pin(7))
spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
ss = Pin(5, Pin.OUT)
display = max7219.Matrix8x8(spi, ss, 1)
display.brightness(15)


buzzer = Pin(18, Pin.OUT)

def beep():
    buzzer.value(1)
    sleep(0.2)
    buzzer.value(0)


def display_hello_world():
    message = "HELLO WORLD"
    display.fill(0)
    for i, char in enumerate(message):
        display.text(char, 0, i * 8)
        display.show()
        sleep(1)


def display_time():
    now = rtc.datetime 
    print("RTC:", now) 
    hours = now[4] 
    minutes = now[5] 
    tm.numbers(hours, minutes)


def main():
    last_minute = -1
    display_hello_world() 

    while True:
        current_time = rtc.datetime
        minutes = current_time[5] 
        display_time()
        

        if minutes != last_minute:
            beep()
            last_minute = minutes
        
        sleep(1)

main()
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
4-Digit Display
GND5VSDASCLSQWRTCDS1307+