"Stranger Things" alphabet sign
Project and Code by Rachel Robinson
/* ========================== Application.cpp =========================== */ #include "application.h" #include "WS2801/WS2801.h" // The colors of the wires may be totally different so // BE SURE TO CHECK YOUR PIXELS TO SEE WHICH WIRES TO USE! // SPARK CORE SPI PINOUTS // http://docs.spark.io/#/firmware/communication-spi // A5 (MOSI) Yellow wire on Adafruit Pixels // A3 (SCK) Green wire on Adafruit Pixels // Don't forget to connect the ground wire to Arduino ground, // and the +5V wire to a +5V supply$ const int numPixel = 25; // Set the argument to the NUMBER of pixels. Adafruit_WS2801 strip = Adafruit_WS2801(numPixel); // For 36mm LED pixels: these pixels internally represent color in a // different format. Either of the above constructors can accept an // optional extra parameter: WS2801_RGB is 'conventional' RGB order // WS2801_GRB is the GRB order required by the 36mm pixels. Other // than this parameter, your code does not need to do anything different; // the library will handle the format change. Example: //Adafruit_WS2801 strip = Adafruit_WS2801(25, WS2801_GRB); void setup() { Spark.function("color", color); Spark.function("message", message); strip.begin(); //color("[000,250,ooo]"); } void loop() { } int color(String command) { // format is [RRR,GGG,BBB] // ie 1st red is [255,000,000] int red = command.substring(1,4).toInt(); int green = command.substring(5,8).toInt(); int blue = command.substring(9,12).toInt(); int i; for (i=0; i < strip.numPixels(); i++) { strip.setPixelColor(i, red, green, blue); strip.show(); } } int message (String command){ color("[204,000,153]"); delay(500); color("000,000,000"); delay(500); for (int i=0; i < command.length(); i++){ String characterholder = command.substring(i, i+1); if (characterholder=="a" || characterholder=="A"){ strip.setPixelColor(24, 255,000,000); delay(500); } if (characterholder=="b"|| characterholder=="B"){ strip.setPixelColor(23, 000,000,255); delay(500); } if (characterholder=="c"|| characterholder=="C"){ strip.setPixelColor(22, 102,255,255); delay(500); } if (characterholder=="d"|| characterholder=="D"){ strip.setPixelColor(21, 255,000,255); delay(500); } if (characterholder=="e"|| characterholder=="E"){ strip.setPixelColor(20, 000,000,204); delay(500); } if (characterholder=="f"|| characterholder=="F"){ strip.setPixelColor(19, 255,102,255); delay(500); } if (characterholder=="g"|| characterholder=="G"){ strip.setPixelColor(18, 051,153,255); delay(500); } if (characterholder=="h"|| characterholder=="H"){ strip.setPixelColor(17, 051,255,051); delay(500); } if (characterholder=="i"|| characterholder=="I"){ strip.setPixelColor(8, 051,051,000); delay(500); } if (characterholder=="j"|| characterholder=="J"){ strip.setPixelColor(9, 255,153,51); delay(500); } if (characterholder=="k"|| characterholder=="K"){ strip.setPixelColor(10,255,102,204); delay(500); } if (characterholder=="l"|| characterholder=="L"){ strip.setPixelColor(11, 000,102,000); delay(500); } if (characterholder=="m"|| characterholder=="M"){ strip.setPixelColor(12, 000,51,204); delay(500); } if (characterholder=="n"|| characterholder=="N"){ strip.setPixelColor(13, 000,151,129); delay(500); } if (characterholder=="o"|| characterholder=="O"){ strip.setPixelColor(14, 102,000,102); delay(500); } if (characterholder=="p"|| characterholder=="P"){ strip.setPixelColor(15,204,255,204); delay(500); } if (characterholder=="q"|| characterholder=="Q"){ strip.setPixelColor(16, 051,051,000); delay(500); } if (characterholder=="r"|| characterholder=="R"){ strip.setPixelColor(7, 153,153,255); delay(500); } if (characterholder=="s"|| characterholder=="S"){ strip.setPixelColor(6, 000,153,051); } if (characterholder=="t"|| characterholder=="T"){ strip.setPixelColor(5, 051,051,204); delay(500); } if (characterholder=="u"|| characterholder=="U"){ strip.setPixelColor(4, 204,000,000); delay(500); } if (characterholder=="v"|| characterholder=="V"){ strip.setPixelColor(3, 255,204,000); delay(500); } if (characterholder=="w"|| characterholder=="W"){ strip.setPixelColor(2, 255,000,102); delay(500); } if (characterholder=="x"|| characterholder=="X"){ strip.setPixelColor(1, 102,153,153); delay(500); } if (characterholder=="y"|| characterholder=="Y"){ strip.setPixelColor(0, 051,102,204); delay(500); } strip.show(); delay(500); color("[000,000,000]"); } }