サンプル ピン割り込み – スイッチ検出 - renesas/micropython GitHub Wiki

image

  • Button Switchを押すと、print(“intr”)が実行されます。

  • RA4M1 Clickerの例:P304を指定します。

from pyb import Pin,ExtInt

callback = lambda e: print("intr")
ext = ExtInt(Pin(Pin.cpu.P304, Pin.IN, Pin.PULL_UP), ExtInt.IRQ_RISING, Pin.PULL_UP, callback)
  • EK-RA6M2 の例:P105を指定します。
from pyb import Pin,ExtInt

callback = lambda e: print("intr")
ext = ExtInt(Pin(Pin.cpu.P105, Pin.IN, Pin.PULL_UP), ExtInt.IRQ_RISING, Pin.PULL_UP, callback)
  • ピン割り込みを実行するには、ピンがIRQを指定できるピンであり、MicroPythonのFirmwareでIRQ割り込みが有効になっている必要があります。