Skip to content

Instantly share code, notes, and snippets.

@goura
Created October 5, 2015 17:10
Show Gist options
  • Save goura/79936b34e49965c9d094 to your computer and use it in GitHub Desktop.
Save goura/79936b34e49965c9d094 to your computer and use it in GitHub Desktop.
# 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