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)

results matching ""

    No results matching ""