From f3eaabfff5e95f646e8de1afdf8e15cced32fdcb Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Fri, 16 Oct 2020 19:07:17 +0200 Subject: [PATCH] Add ExtInt wake-up example. --- .../examples/19-Low-Power/extint_wakeup.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/examples/19-Low-Power/extint_wakeup.py diff --git a/scripts/examples/19-Low-Power/extint_wakeup.py b/scripts/examples/19-Low-Power/extint_wakeup.py new file mode 100644 index 000000000..6bee78a1d --- /dev/null +++ b/scripts/examples/19-Low-Power/extint_wakeup.py @@ -0,0 +1,21 @@ +# ExtInt Wake-Up from Stop Mode Example +# This example demonstrates using external interrupts to wake up from low-power mode. + +import time, pyb, machine +from pyb import Pin, ExtInt + +def callback(line): + pass + +led = pyb.LED(3) +pin = Pin("P5", Pin.IN, Pin.PULL_UP) +ext = ExtInt(pin, ExtInt.IRQ_FALLING, Pin.PULL_UP, callback) + +# Enter Stop Mode. Note the IDE will disconnect. +machine.sleep() + +while (True): + led.on() + time.sleep(100) + led.off() + time.sleep(100)