Raspberry Pico」カテゴリーアーカイブ

実験 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()

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

実験 ADC→LCD SSD1306@Pico,Thonny,Lubuntu22.04
★ SSD1306 インストール

★ 2209051416 LCD SSD1306.py
from machine import Pin, I2C
import ssd1306,time
AD= machine.ADC(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.1)
V= AD.read_u16()*3.3/0xFFFF
print(V)
display.fill(0)
display.text(‘Hello, World!’,0,0,1) # ,x,y,color
display.text(‘SSD1306’,0,8,1)
display.text(‘OLED 128×64’,0,16,1)
display.text(str(V),0,24,1)
display.show()

★ SSD1306本体

 

実験 WDT @Pico,Thonny,Lubuntu22.04

実験 WDT @Pico,Thonny,Lubuntu22.04

★2209031955 WDT.py
import machine,time
LED= machine.Pin(25, machine.Pin.OUT)
WDT= machine.WDT(timeout=2000) #2sec
while 1:
WDT.feed() #clear WDT
time.sleep(0.1); LED.value(1)
time.sleep(0.1); LED.value(0)
time.sleep(0.1); LED.value(1)
time.sleep(0.1); LED.value(0)
time.sleep(1.7) #OK:0.5 1.4 1.5 #NG:1.6 1.7 2