Skip to content

Instantly share code, notes, and snippets.

@richy486
Created September 3, 2014 05:30
Show Gist options
  • Save richy486/283c2b58c7abe625fd20 to your computer and use it in GitHub Desktop.
Save richy486/283c2b58c7abe625fd20 to your computer and use it in GitHub Desktop.
Tweeting raspberry pi button
#!/usr/bin/env python
import sys
from twython import Twython
import RPi.GPIO as GPIO
import time
CONSUMER_KEY = '---- API key here ----'
CONSUMER_SECRET = '---- API secret here ----'
ACCESS_KEY = '---- Access token here ----'
ACCESS_SECRET = '---- Access token secret here ----'
api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
i = 1
while True:
input_state = GPIO.input(18)
if input_state == False:
message = "PANIC (" + str(i) + " total panics)"
print('Button Pressed')
api.update_status(status=message)
# api.update_status(status=sys.argv[1])
i = i + 1
time.sleep(0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment