# Vasilenko Dmitriy K070922/1
from machine import Pin
from utime import sleep
print("Hello, ESP32!")
led = Pin(15, Pin.OUT)
from machine import Pin, I2C
# i2c = I2C(0)
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)
print(i2c.scan())
from ds1307 import DS1307
from machine import I2C, Pin
from time import gmtime, time
# DS1307 on 0x68
I2C_ADDR = 0x68 # DEC 104, HEX 0x68
# define custom I2C interface, default is 'I2C(0)'
# check the docs of your device for further details and pin infos
# this are the pins for the Raspberry Pi Pico adapter board
ds1307 = DS1307(addr=I2C_ADDR, i2c=i2c)
# Print the date and time in ISO8601 format: 2023-04-18T21:14:22
print("Today is {:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}".format(
ds1307.year, ds1307.month, ds1307.day,
ds1307.hour, ds1307.minute, ds1307.second))
from ssd1306 import SSD1306_I2C
oled = SSD1306_I2C(128, 64, i2c)
while True:
if ds1307.weekday in (0, 2, 4) and 9 <= ds1307.hour <= 18:
if ds1307.second < 11:
led.on()
for second in range(10, -1, -1):
oled.text(str(second), 0, 10)
oled.show()
sleep(1)
oled.fill(0)
oled.show()
else:
led.off()