Hi all, heres my tweet to scroll pHAT project i thought you may like to see… it listens to the twitter api for a specified hashtag, currently #saintsfc (possibly the best football team in the world) and sends the tweet to the scrollpHAT.
it currently only gets the first tweet and scrolls it at the moment, but the goal is to display all the live tweets once and then continue to wait for new ones.
im a beginner and this is my first rpiZero project
inspired by the the blinkyStreamer project : blinkystreamer
and also uses the twython library : twitter python library
you just need to enter yout twitter apps details here:-
APP_KEY = ''
APP_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ‘’
import scrollphat import time import RPi.GPIO as GPIO from twython import TwythonStreamer # clear scrollPHat leds scrollphat.clear() scrollphat.set_brightness(10) # Search terms TERMS = '#saintsfc' # Twitter application authentication APP_KEY = '' APP_SECRET = '' OAUTH_TOKEN = '' OAUTH_TOKEN_SECRET = '' # Setup callbacks from Twython Streamer class BlinkyStreamer(TwythonStreamer): def on_success(self, data): if 'text' in data: print data['text'].encode('utf-8') print scrollphat.write_string(data['text'].encode('utf-8')) while True: scrollphat.scroll() time.sleep(0.1) # Create streamer try: stream = BlinkyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) stream.statuses.filter(track=TERMS) except KeyboardInterrupt: GPIO.cleanup()