Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 36 lines (26 sloc) 689 Bytes
#!/usr/bin/env python
import RPi.GPIO as GPIO
KNOCK_PIN = 11
SHOCK_PIN = 13
led_status = 1
def setup():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(SHOCK_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(KNOCK_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def knock_detected(e):
print "KNOCK detected!"
def shock_detected(e):
print "SHOCK detected!"
def loop():
GPIO.add_event_detect(SHOCK_PIN, GPIO.FALLING, callback=shock_detected, bouncetime=200)
GPIO.add_event_detect(KNOCK_PIN, GPIO.FALLING, callback=knock_detected, bouncetime=200)
while True:
pass
def destroy():
GPIO.cleanup()
if __name__ == '__main__':
setup()
try:
loop()
except KeyboardInterrupt:
destroy()