Created
September 4, 2017 17:00
-
-
Save uppfinnarjohnny/ccbebb8c1394a0099e046582dfd8a5da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import urllib.request | |
PIN = 5 | |
LOW_CALLBACK_ADDRESS = 'http://google.com' | |
HIGH_CALLBACK_ADDRESS = 'http://facebook.com' | |
DEBOUNCE_TIME_MS = 200 | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(PIN, GPIO.IN) | |
def on_high(): | |
print('High') | |
urllib2.urlopen(HIGH_CALLBACK_ADDRESS).read() | |
def on_low(): | |
print('Low') | |
urllib2.urlopen(LOW_CALLBACK_ADDRESS).read() | |
GPIO.add_event_detect(PIN, GPIO.RISING, on_high, bouncetime=DEBOUNCE_TIME_MS) | |
GPIO.add_event_detect(PIN, GPIO.FALLING, on_low, bouncetime=DEBOUNCE_TIME_MS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment