Raspberry Pi "Stranger Things" Twitter sign
2017-11-24 | By Kevin Walseth
License: General Public License Arduino Raspberry Pi
Raspberry Pi Stranger things LED sign – Controlled by Twitter
Stranger Things is a Sci-Fi Netflix series based out of the ‘80s. In season 1 when Will goes missing, he starts to communicate with his mom using holiday lights. I have decided to try to replicate this as close as possible and make it somewhat portable.
I big shout-out to Mike Hord from Sparkfun who actually wrote the code for both the Arduino and the Raspberry Pi. The basic code that I started with can be found on Sparkfun’s Github site: https://github.com/sparkfun/Stranger_Things_Wall
My first goal was to get the project up and running. I had a strip of neopixel leds laying around so I hooked these up to the circuit playground and used a simple example code to make sure everything worked. (make sure to add the Adafruit Neopixel library for this to work)
Now it was time to get the Raspberry Pi to read twitter using TwitterSearch Python library. Click here for instructions to install TwitterSearch. You will have to create your own “credentials.py” file from apps.twitter.com. Here is my final python code.
#!/usr/bin/python
from TwitterSearch import *
import re
import serial
from time import sleep
#from credentials import *
regex = re.compile('[^a-zA-Z]')
sft = re.compile('#makewithdigikey')
myPort = serial.Serial('/dev/ttyACM0', 115200, timeout = 10)
myPort.write("Hello world!")
tweet_id_list = []
while True:
try:
print ("Searching...")
tso = TwitterSearchOrder() # create a TwitterSearchOrder object
tso.set_keywords(['#makewithdigikey']) # let's define all words we would like to have a look for
tso.set_include_entities(False) # and don't give us all those entity information
# it's about time to create a TwitterSearch object with our secret tokens
ts = TwitterSearch(
consumer_key = 'your_key_here',
consumer_secret = 'your_secret_here',
access_token = 'your_token_here,
access_token_secret = 'your_token_secret_here'
)
# this is where the fun actually starts :)
for tweet in ts.search_tweets_iterable(tso):
if tweet['id'] not in tweet_id_list:
no_hashtag = sft.sub('', tweet['text'])
text_only = regex.sub('', no_hashtag).encode('ascii', 'ignore')
tweet_id_list.append(tweet['id'])
for character in text_only:
print (character)
myPort.write(character)
sleep(1.0)
except TwitterSearchException as e: # take care of all those ugly errors if there are some
print(e)
sleep(60)
myPort.close()
Now it is time to try the entire system out. Here is the code I ran on the circuit playground.
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 6
#define NUMPIXELS 76
enum CHAR_LEDS {
LR = 1, LS = 3, LT = 6, LU = 9, LV = 12, LW = 15, LX = 18, LY = 21, LZ = 24, LQ = 25,
LP = 28, LO = 31, LN = 34, LM = 37, LL = 40, LK = 43, LJ = 46, LI = 49, LA = 50, LB = 53, LC = 56,
LD = 59, LE = 62, LF = 65, LG = 68, LH = 71
};
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(76, PIN, NEO_GRB + NEO_KHZ800);
int delayVal = 500; // delay for half a second
void setup()
{
Serial.begin(115200);
pixels.begin();
}
void loop()
{
if (Serial.available() > 0)
{
char inchar = Serial.read();
switch(inchar)
{
case 'a':
case 'A':
lightUp(LA);
break;
case 'b':
case 'B':
lightUp(LB);
break;
case 'c':
case 'C':
lightUp(LC);
break;
case 'd':
case 'D':
lightUp(LD);
break;
case 'e':
case 'E':
lightUp(LE);
break;
case 'f':
case 'F':
lightUp(LF);
break;
case 'g':
case 'G':
lightUp(LG);
break;
case 'h':
case 'H':
lightUp(LH);
break;
case 'i':
case 'I':
lightUp(LI);
break;
case 'j':
case 'J':
lightUp(LJ);
break;
case 'k':
case 'K':
lightUp(LK);
break;
case 'l':
case 'L':
lightUp(LL);
break;
case 'm':
case 'M':
lightUp(LM);
break;
case 'n':
case 'N':
lightUp(LN);
break;
case 'o':
case 'O':
lightUp(LO);
break;
case 'p':
case 'P':
lightUp(LP);
break;
case 'q':
case 'Q':
lightUp(LQ);
break;
case 'r':
case 'R':
lightUp(LR);
break;
case 's':
case 'S':
lightUp(LS);
break;
case 't':
case 'T':
lightUp(LT);
break;
case 'u':
case 'U':
lightUp(LU);
break;
case 'v':
case 'V':
lightUp(LV);
break;
case 'w':
case 'W':
lightUp(LW);
break;
case 'x':
case 'X':
lightUp(LX);
break;
case 'y':
case 'Y':
lightUp(LY);
break;
case 'z':
case 'Z':
lightUp(LZ);
break;
default:
break;
}
}
}
void lightUp(CHAR_LEDS charIndex)
{
pixels.setPixelColor(charIndex, pixels.Color(255,255,255));
pixels.show();
delay(delayVal);
pixels.setPixelColor(charIndex, pixels.Color(0,0,0));
pixels.show();
}
Connect the usb from the Circuit Playground up to the Raspberry Pi. This will allow the Circuit Playground to read the serial output from the TwitterSearch on the Pi. You will also make sure to reference the correct tty from the circuit playground in the python code. This is similar to a COM port on a PC. Most likely it will be “ttyUSB0”.
Test it out…. Connect the + from the Neopixel to the VBATT on the CP. And – to GND on the CP. The “D” wire will get connected to pin 6. For this project, you shouldn’t need to connect the neopixels to external power because we are only lighting up 1 LED at a time. If you wanted to run the entire strip, you would need external power for the LEDs.
Is your Pi connected to the web? If so, run the python code and see if it is working (I would suggest using a very common hash tag just to make sure it is printing something.)
Success!!!
Now onto prepping the lights. I just went to my local big box store and bought 2 – 16x20 picture frames and 2 boxes of LED c9 holiday lights. Yes I destroyed them and had fun doing it.
Unscrew the bulbs and pull all the LEDs out of the socket. Then I cut the led socket off right at the base. I cleaned up the cut so it would sit flat on the LED. Then me and my hot-glue gun friend went to work.
The strip is cut into 3 sections with the power coming in bottom left (right next to the letter “R”). I used the green wires from the lights just to make it look legit. I also hot glued on the plug and socket from the holiday lights to look like this was working without being plugged in. Make sure to space out the LEDs how you would like the letters spaced. I had 2 blank LEDs between each letter. Here is my final lettering sequence per row:
LR = 1, LS = 3, LT = 6, LU = 9, LV = 12, LW = 15, LX = 18, LY = 21, LZ = 24, LQ = 25,
LP = 28, LO = 31, LN = 34, LM =37, LL = 40, LK = 43, LJ = 46, LI = 49, LA = 50, LB = 53, LC = 56,
LD = 59, LE = 62, LF = 65, LG = 68, LH = 71
For the background of the sign I found a picture of the Sky Monster to use from season 2. Maybe you have some 80’s wallpaper. Now all that needs to be done is to glue the bulbs above the letters you placed and turn it on.
Be Safe - Demagorgons and Demadogs are out there
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum