#Test not yet debounced:
def callback1(line):
print("IRQ called : ", line)
pin = pyb.Pin.board.X8
extint = pyb.ExtInt(pin, pyb.Extint.IRQFALLING, pyb.GPIO.PULL_UP, callback1)
------------------------------------------------------------------------------
Took the sample of the website but this doesn't work, got syntax-error on the print instruction?
Simple IRQ demo on your site: but what am I doing wrong ?
-
- Posts: 3
- Joined: Mon May 05, 2014 9:11 am
Re: Simple IRQ demo on your site: but what am I doing wrong
There appears to be a documentation error. I was able to get this to work:
The PULL_UP constant is now from the Pin module, so use pyb.Pin.PULL_UP rather then pyb.GPIO.PULL_UP (that's the documentation error).
There was also a typo in your post (you posted Extint.IRQFALLING, where ExtInt.IRQ_FALLING is correct (so ExtInt instead of Extint and the undescore between IRQ and FALLING).
I had to use SW since my pyboard hasn't arrived yet, so I tested with the onboard switch on my netduino board.
Then when I released the switch (on the netduino pushing the switch brings the line high and releasing the switch makes it go low), I see:
Please do note that mechanical switches may bounce, so it is possible to get multiple rising/falling edges.
Code: Select all
Micro Python build 1f85d62-dirty on 2014-05-01; NetduinoPlus2 with STM32F405RG
Type "help()" for more information.
>>> def callback1(line):
... print("IRQ called : ", line)
...
>>> pin = pyb.Pin.board.SW
>>> extint = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback1)
>>>
There was also a typo in your post (you posted Extint.IRQFALLING, where ExtInt.IRQ_FALLING is correct (so ExtInt instead of Extint and the undescore between IRQ and FALLING).
I had to use SW since my pyboard hasn't arrived yet, so I tested with the onboard switch on my netduino board.
Then when I released the switch (on the netduino pushing the switch brings the line high and releasing the switch makes it go low), I see:
Code: Select all
IRQ called : 11
IRQ called : 11
-
- Posts: 3
- Joined: Mon May 05, 2014 9:11 am
Re: Simple IRQ demo on your site: but what am I doing wrong
Thanks Dhylan, it's working great now !