Skip to content

Instantly share code, notes, and snippets.

@ravenbyron
Created September 25, 2017 15:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravenbyron/a8a09d368290158d7a540c85e6d9e7c5 to your computer and use it in GitHub Desktop.
Save ravenbyron/a8a09d368290158d7a540c85e6d9e7c5 to your computer and use it in GitHub Desktop.
Stranger Things Arduino code
#include <FastLED.h>
#include <HashMap.h>
#define DATA_PIN 7 //this is the data pin connected to the LED strip. If using WS2801 you also need a clock pin
#define NUM_LEDS 50 //change this for the number of LEDs in the strip
#define COLOR_ORDER RGB
CRGB leds[NUM_LEDS];
CRGB colors[5];
int myleds[25];
int last_letter = 0;
CRGB white = CRGB(255,255,255);
CRGB red = CRGB (255, 0, 0);
CRGB green = CRGB (0, 255, 0);
CRGB blue = CRGB(0, 0, 255);
CRGB off = CRGB(0, 0, 0);
const byte HASH_SIZE = 28;
HashType<char,int> hashRawArray[HASH_SIZE];
HashMap<char,int> charToLed = HashMap<char,int>( hashRawArray , HASH_SIZE );
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); //setting up the FastLED
randomSeed(analogRead(0)); //seeding my random numbers to make it more random.
myleds[0] = 49;//A
charToLed[0]('a',49);
myleds[1] = 47;//B
charToLed[1]('b',47);
myleds[2] = 45;//C
charToLed[2]('c',45);
myleds[3] = 43;//D
charToLed[3]('d',43);
myleds[4] = 41;//E
charToLed[4]('e',41);
myleds[5] = 39;//F
charToLed[5]('f',39);
myleds[6] = 37;//G
charToLed[6]('g',37);
myleds[7] = 35;//H
charToLed[7]('h',35);
myleds[8] = 18;//I
charToLed[8]('i',18);
myleds[9] = 20;//J
charToLed[9]('j',20);
myleds[10] = 22;//K
charToLed[10]('k',22);
myleds[11] = 24;//L
charToLed[11]('l',24);
myleds[12] = 26;//M
charToLed[12]('m',26);
myleds[13] = 28;//N
charToLed[13]('n',28);
myleds[14] = 30;//O
charToLed[14]('o',30);
myleds[15] = 31;//P
charToLed[15]('p',31);
myleds[16] = 32;//Q
charToLed[16]('q',32);
myleds[17] = 15;//R
charToLed[17]('r',15);
myleds[18] = 13;//S
charToLed[18]('s',13);
myleds[19] = 11;//T
charToLed[19]('t',11);
myleds[20] = 9;//U
charToLed[20]('u',9);
myleds[21] = 7;//V
charToLed[21]('v',7);
myleds[22] = 5;//W
charToLed[22]('w',5);
myleds[23] = 3;//X
charToLed[23]('x',3);
myleds[24] = 1;//Y
charToLed[24]('y',1);
charToLed[25]('z',0);
colors[0] = white;
//colors[1] = red;
//colors[2] = green;
//colors[2] = blue;
colors[1] = off;
reset();
abcs();
}
void loop() {
// myrandomizer(60);
// type("merry christmas");
// myrandomizer(60);
// type("i will get you");
// myrandomizer(60);
// type("happy hanukkah");
// myrandomizer(60);
// type("run");
// myrandomizer(60);
// type("party time");
// myrandomizer(60);
// type("mmmbop");
// myrandomizer(60);
// type("tis the season");
// myrandomizer(60);
// type("leggo my eggo");
myrandomizer(15);
type("go home");
myrandomizer(15);
type("sleepy time");
}
void myrandomizer(int timesec) {
reset();
int loops = timesec * 20;
for (int i = 0; i <= loops; i++) {
int id = random(0, 24);
int l = myleds[id];
leds[l] = randomColor();
FastLED.show();
delay(50);
}
reset();
}
void abcs() {
for (int i = 0; i < 25; i++) {
int t = myleds[i];
leds[t] = white;
FastLED.show();
delay(250);
}
delay(10);
}
CRGB randomColor() {
int t = random(2);
return colors[t];
}
void reset() {
for (int x = 0; x < NUM_LEDS; x++) {
leds[x] = off;
}
FastLED.show();
last_letter = 0;
}
void displayLetter(char letter) {
if(isWhitespace(letter)){
last_letter = 0;
delay(2000);
}
int lednum = charToLed.getValueOf(letter);
if(lednum >= 0 && lednum <= 49) {
if(last_letter == lednum){
delay(2000);
}
leds[lednum] = white;
FastLED.show();
last_letter = lednum;
delay(2000);
leds[lednum] = off;
FastLED.show();
}
}
void type(String message){
reset();
message.toLowerCase();
for(int i =0; i< message.length();i++){
displayLetter(message[i]);
}
reset();
}
@ravenbyron
Copy link
Author

@SmartAlyx2
Copy link

Hi there. :)

Are you still monitoring this Post? I am new to GitHub & signed up so I can speak w/ you about this code inspired to program lights for an Instructables "Stranger Things" display. 1st: Will I receive an alert once you reply to this Post? 2nd: If not I would greatly appreciate an email: SmartAlyx2@gmail.com 3rd: My sister & nephew are huge Stranger Things fans. I would really like to create the x-mas lights display for them. I really want to be able to program it to "write" specific messages. There are 26 letters in this alphabet. Add 0 - 9 numbers = 36 lights needed. Do you recall if Winona Rider painted punctuation marks? If not I would like to add @ least a period & question mark for a total of 38 lights needed. The special programible lights, do they come in the larger bulb size Winona used that have @ least 38 lights? Does your code spell out a message? If so, what? Is it possible to run the special lights off AC instead of DC?

Guess that is enough questions for now. My soon to be 12 year old nephew knows more about programming than I do because of MineCraft. After I get this set up I am going to hopefully know enough to show him how to program his own messages. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment