Interrupts

This commit is contained in:
tilman
2016-12-28 17:32:15 +01:00
parent c70f3257f9
commit 44bcf2942f
3 changed files with 41 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import RPi.GPIO as GPIO
from time import gmtime, strftime
GPIO.setmode(GPIO.BCM)
# Buttons on PINs 9, 10 and 11
GPIO.setup(9, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#sensor on PIN 17
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def btn1_callback(channel):
print("falling edge detected on 9")
def btn2_callback(channel):
print("falling edge detected on 10")
def btn3_callback(channel):
print("falling edge detected on 11")
print(strftime("%Y-%m-%d %H:%M:%S", gmtime()))
GPIO.add_event_detect(9, GPIO.FALLING, callback=btn1_callback, bouncetime=300)
GPIO.add_event_detect(10, GPIO.FALLING, callback=btn2_callback, bouncetime=300)
GPIO.add_event_detect(11, GPIO.FALLING, callback=btn3_callback, bouncetime=300)
try:
GPIO.wait_for_edge(17, GPIO.RISING)
print('Edge detected on channel 17')
except KeyboardInterrupt:
print("Keyboard Interrupt")
finally:
GPIO.cleanup()
print("Cleaned up pins")
Binary file not shown.
+1
View File
@@ -24,6 +24,7 @@
## Gehäuse ## Gehäuse
- Buttons per Acryl-Transfer beschriften? ch.16.05.110-115.pdf - Buttons per Acryl-Transfer beschriften? ch.16.05.110-115.pdf
- Beim Zusammenbau Kamera vor dem Verkleben testen