diff --git a/README.md b/README.md index 48ad69c..0e2af9b 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,14 @@ I used an Adafruit Pro Trinket for mine, which has 150+ lights. Of course, a standard Arduino will work just fine too! +This was coded to color-correct a specific type of GRB LEDs on wires I got from Amazon. +It's coded to match the lights we already have, which are biased toward yellow and amber. + +You may have gotten lights wired RGB, in which case this is going to look very green. +It should be just a matter of switching the first two bytes in each color definition +to go from GRB to RGB. + + Setup ------- @@ -34,7 +42,7 @@ You can plug the LED strip into the +5v on the power supply; You can power your microcontroller from the beefier power supply, too, so you don't have to run USB just to power the microcontroller. -This was coded to color-correct a specific type of GRB LEDs on wires I got from Amazon. -It's coded to match the lights we already have, which are biased toward yellow and amber. -Some of the lights are wired differently and the colors are going to be wrong. -Play around, commenting out all but one color, to see if it's right. +The code as written wants pin 4 to be connected to ground. +When you disconnect it, +the whole strand goes white. +My family has a tradition of the tree going from colors to white on the morning of the 25th. diff --git a/holiday-lights.ino b/holiday-lights.ino index 6ae9e08..866ced3 100644 --- a/holiday-lights.ino +++ b/holiday-lights.ino @@ -6,6 +6,8 @@ #define PIN 6 #define NUM_LEDS 150 +#define WHITE_PIN 4 + Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB | NEO_KHZ800); const uint32_t colors[] = { @@ -24,18 +26,40 @@ const int ncolors = sizeof(colors) / sizeof(*colors); void setup() { strip.begin(); strip.show(); + pinMode(WHITE_PIN, INPUT_PULLUP); } -void loop() { - for (int i = 0; i < 12; i += 1) { +void loop_color() { + for (int i = 0; i < NUM_LEDS/12; i += 1) { int pos = random(NUM_LEDS); if (random(100) < 20) { - int color = random(ncolors); - strip.setPixelColor(pos, colors[color]); - } else { - strip.setPixelColor(pos, 0); - } + int color = random(ncolors); + strip.setPixelColor(pos, colors[color]); + } else { + strip.setPixelColor(pos, 0); + } } strip.show(); delay(240); } + +void loop_white() { + for (int i = 0; i < NUM_LEDS/12; i += 1) { + int pos = random(NUM_LEDS); + if (random(100) < 5) { + strip.setPixelColor(pos, 0x0); + } else { + strip.setPixelColor(pos, 0x99ffaa); + } + } + strip.show(); + delay(24); +} + +void loop() { + if (digitalRead(WHITE_PIN)) { + loop_white(); + } else { + loop_color(); + } +}