Marquee Party Bag
Contributors:
Feldi
Example Code
I am providing two separate programs for you to work with:
- Marquee
- Simple Rainbow Cycle
Example 1: Marquee
The first is the Marquee option. I have added a handful of comments in the code to show you how and where to edit for customization.
//Marquee Party bag by Melissa Felderman for SparkFun Electronics. // Based on Adafruit_NeoMatrix example for single NeoPixel Shield. // Scrolls 'PARTY BAG!' across the matrix in a landscape (horizontal) orientation. Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, 3, 1, PIN, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE, NEO_GRB + NEO_KHZ800); //Inlcude the colors that you would like your writing to reflect in the colors array const uint16_t colors[] = { matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) }; void setup() { matrix.begin(); matrix.setTextWrap(false); matrix.setBrightness(40); matrix.setTextColor(colors[0]); } int x = matrix.width(); int pass = 0; void loop() { matrix.fillScreen(0); matrix.setCursor(x, 0); matrix.print(F("PARTY BAG!")); //replace 'PARTY BAG!' with your personal message if(--x < -36) { x = matrix.width(); if(++pass >= 3) pass = 0; //if you included more than three colors in the color array, change the number in the if statement to reflect that amount matrix.setTextColor(colors[pass]); } matrix.show(); delay(100); }
Example 2: Simple Rainbow Cycle
The second is a simple rainbow cycle.
//rainbow LED bag by Melissa Felderman for Spsarfun //This sketch is an edited version of the Adafruit Neopixel Strand Test example code from the Neopixel Library. Adafruit_NeoPixel strip = Adafruit_NeoPixel(198, PIN, NEO_GRB + NEO_KHZ800); void setup() { // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket if (F_CPU == 16000000) clock_prescale_set(clock_div_1); // End of trinket special code strip.begin(); strip.show(); // Initialize all pixels to 'off' } void loop() { rainbow(20); rainbowCycle(20); theaterChaseRainbow(50); } void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } // Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } //Theatre-style crawling lights with rainbow effect void theaterChaseRainbow(uint8_t wait) { for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel for (int q=0; q < 3; q++) { for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on } strip.show(); delay(wait); for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); }
When you are ready, pick your program, copy it, and paste it into a new window in your Arduino IDE. Make sure the correct board is selected by going to Tools > Board > Lilypad Arduino USB. Then, connected your Lilypad to your computer via USB. Turn the Lilypad on, and select the active port from Tools > Port. Now all you need to do is upload the program to your Lilypad by hitting the upload button!