loading
3Comments

Tell us about yourself!

Complete Your Profile
  • egambo commented on bxl4662's instructable Arduino Based Stranger Things Lights2 months ago
    Arduino Based Stranger Things Lights

    I used your code and for some reason every time there is a space in my phrase, it finishes the word prior to the space just fine.....pauses....and then displays the last letter of the word before the space again and then continues on as it should... Any ideas?

    #include <FastLED.h>#include <HashMap.h>#define DATA_PIN 6 //this is the data pin connected to the LED strip. If using WS2801 you also need a clock pin#define NUM_LEDS 100 //change this for the number of LEDs in the strip#define COLOR_ORDER RGBCRGB 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 numbe...see more »#include <FastLED.h>#include <HashMap.h>#define DATA_PIN 6 //this is the data pin connected to the LED strip. If using WS2801 you also need a clock pin#define NUM_LEDS 100 //change this for the number of LEDs in the strip#define COLOR_ORDER RGBCRGB 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] = 4;//A charToLed[0]('a',4); myleds[1] = 7;//B charToLed[1]('b',7); myleds[2] = 10;//C charToLed[2]('c',10); myleds[3] = 12;//D charToLed[3]('d',12); myleds[4] = 15;//E charToLed[4]('e',15); myleds[5] = 18;//F charToLed[5]('f',18); myleds[6] = 22;//G charToLed[6]('g',22); myleds[7] = 24;//H charToLed[7]('h',24); myleds[8] = 63;//I charToLed[8]('i',63); myleds[9] = 59;//J charToLed[9]('j',59); myleds[10] = 55;//K charToLed[10]('k',55); myleds[11] = 53;//L charToLed[11]('l',53); myleds[12] = 50;//M charToLed[12]('m',50); myleds[13] = 49;//N charToLed[13]('n',49); myleds[14] = 45;//O charToLed[14]('o',45); myleds[15] = 42;//P charToLed[15]('p',42); myleds[16] = 38;//Q charToLed[16]('q',38); myleds[17] = 71;//R charToLed[17]('r',71); myleds[18] = 74;//S charToLed[18]('s',74); myleds[19] = 76;//T charToLed[19]('t',76); myleds[20] = 79;//U charToLed[20]('u',79); myleds[21] = 82;//V charToLed[21]('v',82); myleds[22] = 85;//W charToLed[22]('w',85); myleds[23] = 88;//X charToLed[23]('x',88); myleds[24] = 90;//Y charToLed[24]('y',90); charToLed[25]('z',94); colors[0] = white; colors[1] = red; colors[2] = green; colors[3] = blue; colors[4] = off; reset(); abcs();}void loop() { //myrandomizer(60); type("there is only zuul"); //myrandomizer(60); type("merry christmas"); //myrandomizer(60); type("i will get you"); //myrandomizer(60); type("happy hanukkah"); //myrandomizer(60); type("spank me"); //myrandomizer(60); type("tis the season");}void myrandomizer(int timesec) { reset(); int loops = timesec * 20; for (int i = 0; i <= loops; i++) { int id = random(0, 25); 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(4); 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 <= 99) { 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();}

    View Instructable »