Skip to content

Instantly share code, notes, and snippets.

@sfnis
Created December 30, 2018 01:51
Show Gist options
  • Save sfnis/1326f904b31b0eff79e4108cb9edb04a to your computer and use it in GitHub Desktop.
Save sfnis/1326f904b31b0eff79e4108cb9edb04a to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
import time
SENSOR_PIN = 23
GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN)
def my_callback(channel):
# Here, alternatively, an application / command etc. can be started.
print('There was a movement!')
curl -d '' http://172.16.32.210:8060/keypress/Power
try:
GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING, callback=my_callback)
while True:
time.sleep(100)
except KeyboardInterrupt:
print "Finish..."
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment