http://jh7ubc.web.fc2.com/Raspberry_Pi/Raspberry_Pi_Pico/Pi_Pico_AQM0802A.html
ちあんとうごいた
from machine import Pin, I2C
import utime
i2c = I2C(0,freq=100000,scl=Pin(17),sda=Pin(16))
addr=0x3e
buf=bytearray(2)
def write_cmd(cmd):
buf[0]=0x00
buf[1]=cmd
i2c.writeto(addr,buf)
def write_char(char):
buf[0]=0x40
buf[1]=char
i2c.writeto(addr,buf)
def print(str):
for c in str:
write_char(ord(c))
def LCD_cursor(x,y):
if y==0:
write_cmd(0x80+x)
if y==1:
write_cmd(0xc0+x)
def LCD_clear():
buf[0]=0x00
buf[1]=0x01
i2c.writeto(addr,buf)
utime.sleep(0.001)
def LCD_home():
buf[0]=0x00
buf[1]=0x02
i2c.writeto(addr,buf)
utime.sleep(0.001)
def LCD_init():
orders = [b'\x38', b'\x39', b'\x14', b'\x73', b'\x56', b'\x6c',b'\x38', b'\x0c', b'\x01']
utime.sleep(0.04)
for order in orders:
i2c.writeto_mem(addr, 0x00, order)
utime.sleep(0.001)
LCD_init()
LCD_clear()
LCD_home()
print('JH7UBC')
num=0
while True:
LCD_cursor(0,1)
print(str(num))
num=num+1
utime.sleep(1)
0 件のコメント:
コメントを投稿