From c4642616b38aee7a30e4a4e14babfb351b779c67 Mon Sep 17 00:00:00 2001 From: White Moustache Date: Sat, 13 Feb 2016 14:17:08 +0000 Subject: [PATCH] examples: wiringPiISR usage example --- examples/callback.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/callback.py diff --git a/examples/callback.py b/examples/callback.py new file mode 100644 index 0000000..72f54f0 --- /dev/null +++ b/examples/callback.py @@ -0,0 +1,14 @@ +import wiringpi2 +PIN_TO_SENSE = 23 + +def gpio_callback(): + print "GPIO_CALLBACK!" + +wiringpi2.wiringPiSetupGpio() +wiringpi2.pinMode(PIN_TO_SENSE, wiringpi2.GPIO.INPUT) +wiringpi2.pullUpDnControl(PIN_TO_SENSE, wiringpi2.GPIO.PUD_UP) + +wiringpi2.wiringPiISR(PIN_TO_SENSE, wiringpi2.GPIO.INT_EDGE_BOTH, gpio_callback) + +while True: + wiringpi2.delay(2000)