This blog post will explain how to capture hex values from keypresses on an IR remote. First, the required libraries have to be imported. A variable named pin_ir has to be initialized to pin 0 and set as an input. The callback function is declared and it sorts out repeat codes from codes from button presses. NEC remotes send out repeat codes. The variable ir will initialize the ir receiver using variables pin_ir and callback as arguments.from machine import Pin, freq
from picobricks import NEC_16
pin_ir = Pin(0, Pin.IN)
def callback(data, addr, ctrl):
if data < 0:
pass
else:
print(f”Hex Data 0x{data:02x}”)
ir = NEC_16(pin_ir, callback)
The Picobricks zero to hero kit was used to write this blog post.