[uPyCraft IDE]3.2.11 NecIR

2020-7-21 14:00:00 [显示全部楼层]
2617浏览
查看: 2617|回复: 0

[uPyCraft IDE] 3.2.11 NecIR

[复制链接]

NecIR模块中提供了与红外遥控相关的函数。

class machine.NecIR(pin)

pin:引脚
    Pin(0)、Pin(5)、Pin(9)、Pin(10)、Pin(14)
    Pin(15)、Pin(16)、Pin(17)、Pin(18)、Pin(19)、
    Pin(21)、Pin(22)、Pin(23)、Pin(26)、Pin(27) 、
    Pin(34)、Pin(35)、Pin(36) 、Pin(39)

定义NecIR

示例:

from machine import NecIR, Pin

ir = NecIR(Pin(0))

类函数

NecIR.Read(hander)

函数说明:设置红外回调函数。

hander:回调函数名称
       回调函数定义格式:
    def <函数名>(addr, cmd):
    ……
       其中,addr为红外地址码,cmd为红外命令码

示例:

def fun(addr,cmd):
  print('addr=', hex(addr))
  print('cmd=', hex(cmd))

ir.read(fun)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail