author

YouDontSurfFU

Inbox View Profile
1Comments

Tell us about yourself!

  • Here's a better version if you install the FastLED library: #include <FastLED.h>template<typename T, size_t N> constexpr size_t countof(const T(&)[N]) { return N; }CRGB leds[50];// Christmas light colorsCRGB colors[] = {//yellow 0xFFA500,//white 0xFFFFFF,//green 0x008000, //aqua 0x00FFFF,//red 0xFF0000, //blue 0x0000FF};// An array to store which color is at which index is// used so that the color of each LED stays the same.// Values are generated in setup().uint8_t index[countof(leds)];void setup() { for (auto &color : colors) napplyGamma_video(color, 2.2); index[0] = random8(countof(colors)); for (size_t i = 1; i < countof(leds); i++) { index[i] = random8(countof(colors)-1); if (index[i] == index[i-1]) index[i] = countof(colors)-1;} FastLED…

    see more »

    Here's a better version if you install the FastLED library: #include <FastLED.h>template<typename T, size_t N> constexpr size_t countof(const T(&)[N]) { return N; }CRGB leds[50];// Christmas light colorsCRGB colors[] = {//yellow 0xFFA500,//white 0xFFFFFF,//green 0x008000, //aqua 0x00FFFF,//red 0xFF0000, //blue 0x0000FF};// An array to store which color is at which index is// used so that the color of each LED stays the same.// Values are generated in setup().uint8_t index[countof(leds)];void setup() { for (auto &color : colors) napplyGamma_video(color, 2.2); index[0] = random8(countof(colors)); for (size_t i = 1; i < countof(leds); i++) { index[i] = random8(countof(colors)-1); if (index[i] == index[i-1]) index[i] = countof(colors)-1;} FastLED.addLeds<WS2811, 6, RGB>(leds, countof(leds)); FastLED.setBrightness(255); // Fill and show LEDs for (size_t i = 0; i < countof(leds); i++) leds[i] = colors[index[i]]; FastLED.show(); // Message trigger delay(5000); // Flicker generator for (int i = 0; i <90; i++) { if (random8() > ease8InOutQuad(i*2)) FastLED.show(); else // To prevent having to repopulate leds[], we // simply show black instead of clearing the array. FastLED.showColor(CRGB::Black); delay(33); } // Finally clear the array so that the LEDs don't // relight when we show our message FastLED.clear();}void loop() { // Spaces are moved to before the message so that there's a pause // after the flicker. Could be replaced with a delay() in setup(). FastLED.clear(); write(" Message One"); write(" Message Two"); write(" Message Three"); // Fill and show LEDs for (size_t i = 0; i < countof(leds); i++) leds[i] = colors[index[i]]; FastLED.show(); // Message trigger delay(4000); // Flicker generator for (int i = 0; i <90; i++) { if (random8() > ease8InOutQuad(i*2)) FastLED.show(); else // To prevent having to repopulate leds[], we // simply show black instead of clearing the array. FastLED.showColor(CRGB::Black); delay(33); }}//May not be needed. This accounts for LED pixels skipped or not used for the 2nd and 3rd rowsint getIndex(char c) { c = toUpperCase(c); switch (c) { case 'A'...'H': return 50 - (c - 'A'); case 'I'...'P': return 30 + (c - 'I'); case 'Q': return 39; case 'R'...'Y': return 26 - (c - 'R'); case 'Z': return 17; default: // Should never happen, but is here to avoid compiler warnings return 0; }}void write(char c) { if (isAlpha(c)) { // Get index and convert to 0-based indexing int i = getIndex(c)-1; leds[i] = colors[index[i]]; FastLED.show(); delay(750); leds[i] = CRGB::Black; FastLED.show(); delay(250); } else if (isSpace(c)) { delay(1000); }}void write(const char *str) { while (*str) write(*str++);}

    View Instructable »