注册 登录
电子工程世界-论坛 返回首页 EEWORLD首页 频道 EE大学堂 下载中心 Datasheet 专题
hanyeguxingwo的个人空间 https://home.eeworld.com.cn/space-uid-288414.html [收藏] [复制] [分享] [RSS]
日志

PYB Nano驱动8*8LED点阵心形显示

已有 929 次阅读2016-12-10 19:17 |个人分类:MicroPython

         此次使用PYB Nano的GPIO直接驱动8*8LED点阵显示,LED点阵引脚分为两排,如下图所示,其中又分为行列引脚,当行引脚为高电平、列引脚为低电平时,LED被全部点亮。


【1】硬件连接:

【2】程序源码:
  1. # main.py -- put your code here!
  2. import  pyb
  3. from pyb import Pin
  4. x_PIN = [Pin(i, Pin.OUT_PP) for i in ['X4','X5','X6','X7','X8','X9','X10','X11']]
  5. y_PIN = [Pin(i, Pin.OUT_PP) for i in ['Y0','Y1','Y2','Y3','Y4','Y5','Y6','Y7']]
  6. hanzi=['11111111','11011101','10001000','10000000','10000000','11000001','11100011','11110111']
  7. def displayLED():
  8.     flag=0
  9.     for x_ in range(0,8):
  10.         for b in range(0,8):
  11.             print(b)
  12.             if b!=flag:
  13.                 x_PIN[b].value(0)
  14.         li_l = hanzi[x_]
  15.         y_PIN[0].value(int(li_l[:1]))
  16.         y_PIN[1].value(int(li_l[1:2]))
  17.         y_PIN[2].value(int(li_l[2:3]))
  18.         y_PIN[3].value(int(li_l[3:4]))
  19.         y_PIN[4].value(int(li_l[4:5]))
  20.         y_PIN[5].value(int(li_l[5:6]))
  21.         y_PIN[6].value(int(li_l[6:7]))
  22.         y_PIN[7].value(int(li_l[7:8]))
  23.         x_PIN[flag].value(1)
  24.         flag=flag+1
  25.         pyb.delay(2)
  26. while 1:
  27.     displayLED()
复制代码
【3】显示效果:




本文来自论坛,点击查看完整帖子内容。

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

热门文章