Created
October 5, 2015 17:10
-
-
Save goura/79936b34e49965c9d094 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
# Based on the example code on http://razzpisampler.oreilly.com/ch07.html | |
import RPi.GPIO as GPIO | |
import urllib | |
import time | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
def button_pressed(): | |
print('button pressed') | |
data = urllib.urlencode({'text': 'hello!'}) | |
print(data) | |
urllib.urlopen('http://beam.soracom.io:8888/', data) | |
while True: | |
input_state = GPIO.input(18) | |
if input_state == False: | |
button_pressed() | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment