I did make the “Raspberry Pi Twitter Monitor” from SPARKFUN (SHAWN HYMEL) and it is working perfectly.
Now i want to use a .wav into this project, so when the ‘LED’ is turned on and off (via a Twitter-program and an IFTTT-program), the .wav is automaticly played. Now i do have the ‘LED’ is working when a hashtag is used.
I did install Speaker pHat and it is working oke. Can i put a trigger into the script for Raspberry pi , so the .wav is playing? Or am i totally wrong with this? (i am a newbee…and did search around but … .
My .py - script is : (name of my script is : pi_code.py)
Moderator edit to add code formatting.
import time
import RPi.GPIO as GPIO
from twython import TwythonStreamer
# Search terms - Use a unique hashtag here eg. '#ISSoverheadMyStreet'
TERMS = '#ISSoverhead'
# Setup GPIO as output
GPIO.setmode(GPIO.BOARD)
# GPIO pin number of LED
LED = 22
GPIO.setup(LED, GPIO.OUT)
GPIO.output(LED, GPIO.LOW)
# Twitter application authentication
APP_KEY = 'YourTwitterInfoHere'
APP_SECRET = 'YourTwitterInfoHere'
OAUTH_TOKEN = 'YourTwitterInfoHere'
OAUTH_TOKEN_SECRET = 'YourTwitterInfoHere'
# Setup callbacks from Twython Streamer
class BlinkyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
print data['text'].encode('utf-8')
print
i=0
while i < 40:
GPIO.output(LED,1)
time.sleep(0.5)
GPIO.output(LED,0)
time.sleep(0.5)
i = i + 1
# Create streamer
try:
stream = BlinkyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
stream.statuses.filter(track=TERMS)
except KeyboardInterrupt:
GPIO.cleanup()
Can i put somewhere a trigger in "def on_succes(self, data) ?
The .wav (the name is : Eagle-Has-Landed_Audio.wav and is in /home/pi map installed) can i play
with : aplay /home/pi/Eagle-Has-Landed-Audio.wav (command in the LX terminal)
Or do i have to make a new .py (creating a V2 ?..what is a V2?..) and reboot it together with the pi_code.py ?
Please , can somebody help me.?..i am at the end of my search…Thanks anyway…
Grts…Guido M from Belgium