// Low power NeoPixel earrings example. Makes a nice blinky display // with just a few LEDs on at any time...uses MUCH less juice than // rainbow display! #include #define PIN 0 #define FIRE_SIZE 15 #define RED_SIZE 12 #define LIGHTNING_SIZE 14 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIN); uint8_t mode = 0, // Current animation effect offset = 0; // Position of spinny eyes uint32_t color = 0xffffff; // Start red uint32_t prevTime; uint8_t m = 0; uint32_t waiting = 8000; const uint32_t mix[] = { 0xff00ff, 0x8f00ff, 0xf000ff }; const uint32_t breathe[] = {7, 7, 15, 23, 30, 38, 45, 52, 58, 64, 70, 76, 80, 85, 89, 92, 95, 97, 98, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 98, 97, 95, 92, 89, 85, 80, 76, 70, 64, 58, 52, 45, 38, 30, 23, 15, 7 }; const uint32_t fire[] = { 0xff2426, 0xfe3223, 0xfe4121, 0xfd4f1f, 0xfd5e1d, 0xfc6d1b, 0xfc7b18, 0xfb8a16, 0xfb9814, 0xfaa712, 0xfab610, 0xffc20d, 0xffd30b, 0xffe309, 0xfff407, 0xf7ff05 }; const uint32_t lightning[] = { 0xffffff, 0x2436ff, 0x2e43fe, 0x3950fe, 0x4354fe, 0x4e6bfe, 0xffffff, 0x5879fe, 0x6386fe, 0x6d93fe, 0x78a1fe, 0x82aefe, 0x8dbcfe, 0x97c9fe, 0xa2d6fe, 0xace4fe }; // ,0xc2fffe, , , , , , , , , , }; const uint32_t reds[] = { 0xf4c262, 0xff6961 , 0xff5c5c, 0xff1c00, 0xff0800, 0xff0000, 0xcd5c5c, 0xe34234, 0xd73b3e, 0xce1620, 0xcc0000, 0xb22222 }; //, , , , , , , , , , , 0xb31b1b}; void setup() { pixels.begin(); pixels.setBrightness(10); // 1/3 brightness prevTime = millis(); } void loop() { uint8_t i; uint32_t t; uint8_t B; switch (mode) { case 0: // Random sparks - just one LED on at a time! // pixels.setPixelColor(0, color); pixels.show(); delay(1000); break; case 1: // Spinny wheels (8 LEDs on at a time) B = breathe[m]; // color = fire[random(FIRE_SIZE)]; // color = lightning[random(LIGHTNING_SIZE)]; color = 0xff0000; pixels.setPixelColor(0, color); pixels.setBrightness(B); pixels.show(); m++; if (m > 49) { m = 0; } delay(60); break; case 2: color = reds[random(RED_SIZE)]; // color = lightning[random(LIGHTNING_SIZE)]; pixels.setPixelColor(0, color); pixels.show(); delay(120); break; } t = millis(); if ((t - prevTime) > waiting) { // color = fire[random(FIRE_SIZE)]; mode++; m = 0; if (mode > 2) { mode = 0; } switch (mode) { case 0: waiting = 8000; color = 0xff0000; // color = 0x007fff; break; case 1: waiting = 30000; break; case 2: waiting = 30000; pixels.setBrightness(60); break; } //color = rgb[random(3)]; prevTime = t; } }