@appare

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

ラズパイ4でLCDに文字表示をうまくできません。

解決したいこと

ラズパイ4のLCD表示をさせるのにうまくできません。

RaspberryPiのThonnyで書いています。
lcdはACM1602NI-FLW-FBW-M01

1行目に「hare」
2行目に「kumori」と表示させたいのに
なぜだかうまくいきません。

ご指摘ください。
IMG_4569.jpg

import smbus
import time

i2c=smbus.SMBus(1)

intLcd=[0x38,0x01,0x0c,0x06]

tenkitxt=['hare','kumori']

lcdLine=[0x80,0xc0]
lineNum=False

for command in intLcd:
    i2c.write_byte_data(0x50,0x00,command)
    time.sleep(0.02)

for tenki in range(2):
    i2c.write_byte_data(0x50,0x00,lcdLine[lineNum])
    time.sleep(0.02)
    lineNum=not lineNum

for txt in tenkitxt[tenki]:
    i2c.write_byte_data(0x50,0x80,ord(txt))
    time.sleep(0.02)

追記
なんとなく改善できました。
最後の空白が意味あったようです。

    for txt in tenkitxt[tenki]:
        i2c.write_byte_data(0x50,0x80,ord(txt))
        time.sleep(0.02)

ありがとうございます。

0 likes

No Answers yet.

Your answer might help someone💌