Micro Python 入门教程---第三个Micro Python LCD5110显示6x8字符

TPYboard控制LCD5110显示6x8字符
先看一下LCD5110针脚含义吧(注意:LCD5110的针脚有些不一样的)
TPYBoard的针脚与5110的针脚对应关系如下:

TPYBoard       LCD5110    memo
————————————————————————————
# any   Pin        => RST       Reset pin (0=reset, 1=normal)
# any   Pin        => CE        Chip Enable (0=listen for input,   1=ignore input)
# any   Pin        => DC        Data/Command (0=commands, 1=data)
#   MOSI          => DIN       data flow (Master out, Slave in)
#   SCK           => CLK       SPI clock
# 3V3   or any Pin  => VCC       3.3V logic voltage (0=off, 1=on)
# any   Pin        => LIGHT     Light (0=on, 1=off)
#   GND           => GND


还是看不明白的话,直接上针脚编号吧
TPYBoard       LCD5110    memo
————————————————————————————
Y10        => RST       Reset pin (0=reset, 1=normal)
Y11        => CE        Chip Enable (0=listen for input,1=ignore input)
Y9         => DC        Data/Command (0=commands, 1=data)
X8         => DIN       data flow (Master out, Slave in)
X6         => CLK       SPI clock
VCC
Y12        => LIGHT     Light (0=on, 1=off)

GND


接线ok后,可运行main.py了。



main.py 源代码:
#main.py
import pyb
import upcd8544
from machine import SPI,Pin
  
def main():
    SPI    = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK
    #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in)
    #CLK =>SPI(1).SCK  'X6' SPI clock
    
    RST    = pyb.Pin('Y10')
    CE     = pyb.Pin('Y11')
    DC     = pyb.Pin('Y9')
    LIGHT  = pyb.Pin('Y12')
    lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT)
    
    lcd_5110.lcd_write_string('Hello Python!',0,0)
    lcd_5110.lcd_write_string('Micropython',6,1)
    lcd_5110.lcd_write_string('TPYBoard',12,2)
    lcd_5110.lcd_write_string('v102',60,3)
    lcd_5110.lcd_write_string('This is a test of LCD5110',0,4)
    
  
if __name__ == '__main__':
    main()






  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值