N
@robert-hh
Thank you Robert. That did indeed solve my problem, and the code below does now work.I appreciate you help and response.
In my defense, I was totally mislead by the Pycom documents on pin callback, which i copy here.
It says arg is optional and can be left empty or set toNone. I had left the wrong arg empty as you saw. Leaving the arg empty returns "Unhandled exception in callback handler etc etc". I had also tried (None) which caused a syntax error. I now realise that when they said "leave arg empty" they were talking about "arg=None" in this line:
p_in.callback(Pin.IRQ_FALLING,pin_handler,arg=None)
and not "arg" in this line :
def pin_handler(arg):
Here is the working code for anyone following on.
#Pin interrupt
import machine
from machine import Pin
from time import sleep
p11 = Pin('P11',mode=Pin.IN,pull=Pin.PULL_UP)
def pin_handler(p):
print('got int on P11',p)
p11.callback(Pin.IRQ_FALLING,pin_handler)
while True:
print ('in main')
sleep(2)