import time
from machine import Pin

from nec import NEC_8  # NEC remote, 8 bit addresses



def callback(data, addr, ctrl):
    if data < 0:  # NEC protocol sends repeat codes.
        print('Repeat code.')
    else:
        print('Data {} Addr {:04x}'.format(data, addr))

ir = NEC_8(Pin(13, Pin.IN), callback)
while True:
    time.sleep_ms(500)