3
在树莓派4B上使用LCD1602液晶屏
source link: https://direct5dom.github.io/2021/10/31/%E5%9C%A8%E6%A0%91%E8%8E%93%E6%B4%BE4B%E4%B8%8A%E4%BD%BF%E7%94%A8LCD1602%E6%B6%B2%E6%99%B6%E5%B1%8F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
LCD1602技术原理
LCD1602可以显示16 x 2个字符,且只支持标准ASCII码字符和日文希腊文字符。
LCD1602一共有16个针脚,如果直接将其连接在树莓派上的话非常占用资源,所以我这里用的是和 I2C(I2C)模块集成在一起的板子。I2C 只有四个针脚,这样就可以大幅度节约树莓派针脚去干其他事,I2C接口引脚如下:
引脚 | 功能 |
---|---|
GND | 接地 |
VCC | 控制电压 |
SDA | I2C数据 |
SCL | I2C时钟 |
安装i2c-tools
使用命令:
sudo apt install i2c-tools |
安装python-smbus
使用命令:
sudo apt install python-smbus |
查看I2C设备地址
使用命令及返回:
$ sudo i2cdetect -y 1 |
看到地址为0x27。这说明已经成功连接了1602A 。接下来就可以控制1602A显示信息了。
驱动程序LCD1602.py
:
import time |
显示时间的示例程序time.py
:
#!/user/bin/env python |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK