実験 RTC→LCD SSD1306@Pico,Thonny,Lubuntu22.04

実験 RTC→LCD SSD1306@Pico,Thonny,Lubuntu22.04

★ 2209061702 RTC LCD SSD1306.py

from machine import Pin, I2C
import ssd1306,time

rtc = machine.RTC()
rtc.datetime((2022, 9, 6, 3, 19, 34, 36, 0))

i2c= I2C(0,sda=Pin(16),scl=Pin(17),freq=400000) # using default address 0x3C
print (i2c.scan()) #0x3C=60
display= ssd1306.SSD1306_I2C(128,64,i2c)

while 1:
time.sleep(0.3)
t= rtc.datetime()
print(‘{}/{:2}/{:2} {:2}:{:2}:{:2}’.format(t[0],t[1],t[2],t[4],t[5],t[6]))
display.fill(0)
display.text(‘RTC to SSD1306’,0,0,1) # ,x,y,color
display.text((‘{:4}/{:2}/{:2}’.format(t[0],t[1],t[2])),0, 8,1)
display.text((‘{:2}:{:2}:{:2}’.format(t[4],t[5],t[6])),0,16,1)
display.show()