To avoid being too overwhelming, the default code has everything a single color by default. We can amp this up, but it’s going to involve more numbers.
First, look again at the palette[] section of the code:
uint8_t palette[][3] = { { 0, 255, 0 }, // Bright green ectoplasm };
This can be expanded to a list of colors. Each {in curly braces} is three numbers — red, green and blue components, each in the range 0 to 255. Mind your commas and formatting!
For a Fourth of July aesthetic, one might choose a palette like this:
uint8_t palette[][3] = { { 255, 0, 0 }, // Color 0 = Red { 255, 255, 255 }, // Color 1 = White { 0, 0, 255 }, // Color 2 = Blue };
Next we tell the drips[] table what colors to use, using indices into the palette[] array. Because of the way C arrays work, this numbering starts at 0.
The last two numbers for each drip are the lowest and highest color palette indices to use. A color within this range will be randomly picked each time a new drip starts there:
} drip[] = { { 16, 7, 0.157, 0, 2 }, // Randomly pick from palette 0-2 { 19, 6, 0.174, 0, 2 }, { 18, 5, 0.195, 0, 2 }, { 17, 6, 0.16 , 0, 2 }, { 16, 1, 0.21 , 0, 2 }, { 16, 1, 0.21 , 0, 2 }, { 21, 10, 0.143, 0, 2 }, };
Perhaps you just want each drip a distinct color, not randomized. NeoPixel rainbows are popular…maybe a bit overdone, but some occasions do call for it. One sets up a color palette:
uint8_t palette[][3] = { { 255, 0, 0 }, // 0 = Red { 255, 160, 0 }, // 1 = Orange { 255, 255, 0 }, // 2 = Yellow { 0, 255, 0 }, // 3 = Green { 0, 255, 255 }, // 4 = Cyan { 0, 0, 255 }, // 5 = Blue { 192, 0, 255 }, // 6 = Purple };
…and then, in the drip[] array, both numbers at the end of each drip are set to the same palette index:
} drip[] = { { 16, 7, 0.157, 0, 0 }, // Always use palette[0] for this drip { 19, 6, 0.174, 1, 1 }, // and palette[1] for this drip { 18, 5, 0.195, 2, 2 }, // and so forth... { 17, 6, 0.16 , 3, 3 }, { 16, 1, 0.21 , 4, 4 }, { 16, 1, 0.21 , 5, 5 }, { 21, 10, 0.143, 6, 6 }, };
It’s possible and valid to mix and match these rules, so drips can operate in a combination of fixed colors, random selections, or groups of each. It’s all in how those last two numbers are set.
Icicle Effect
The upper “dribbling” section of each strip can be partially lit to give a sort of icicle effect, with each drop pausing there before dropping. This can be seen in the Holiday Icicle Lights with Flair guide (but looks great with icky ectoplasm too!)
Near the top of the code, look for:
#define ICE_BRIGHTNESS 0 // Icycle effect Brightness (0 to <100%)
Bump that number up a little…10 to 25 works well, probably don’t want more than that.
This effect does not pair well with the color randomization explained earlier (but is fine with multiple fixed-color drips). The code works, it just looks bad when the icicles switch hue.
Carrie Mode
Firepixie was incorporating this code into a gorgeous LED-festooned dress and had a twisted idea: could there be a switch to turn the normally beautiful lights into blood? This required only minimal changes, so yes, it’s in there, but disabled by default.
This requires adding either a SPST toggle switch or a momentary pushbutton (held down for as long as the effect is active) connected between ground and any unused I/O pin, or between two I/O pins.
To use this effect, add one extra color at the end of the palette[] array. For example, one might have three pretty winter colors, and then suddenly, BLOOD:
uint8_t palette[][3] = { { 0, 0, 255 }, // Color 0 = Blue { 127, 255, 255 }, // Color 1 = Teal { 255, 255, 255 }, // Color 2 = White { 255, 0, 0 }, // Color 3 = Red };
The drips only reference the first three colors (0–2). The fourth color (#3) is not mentioned in the drip[] table. It’s a secret extra thing.
} drip[] = { { 16, 7, 0.157, 0, 2 }, // Randomly pick from palette 0-2 { 19, 6, 0.174, 0, 2 }, { 18, 5, 0.195, 0, 2 }, { 17, 6, 0.16 , 0, 2 }, { 16, 1, 0.21 , 0, 2 }, { 16, 1, 0.21 , 0, 2 }, { 21, 10, 0.143, 0, 2 }, };
There are two lines in the code, both commented out by default, that enable this feature. Remember that you must have a switch or button to use this.
//#define CARRIE_PIN A2 //#define CARRIE_GROUND A3
Un-comment the first line, change the pin number if you like, and then connect a switch or button between this pin and any ground pin:
#define CARRIE_PIN A2
Sometimes a project is already using every ground pin on the board. That’s okay…if another GPIO pin is available, you can use this as a makeshift ground for the other side of your switch or button to connect to:
#define CARRIE_GROUND A3
This second pin, if enabled, is strictly a signal ground. It’s working off a GPIO pin and should not be used for carrying any substantial load like additional NeoPixels.
Enabling Carrie mode is not an instantaneous *poof* switchover. Each drip currently in motion will continue in its current color, and only switches over at the start of its next “ooze.” This gives a nice effect as the NeoPixel strips gradually change over one by one. As with the random color option, this doesn’t pair well with the icicle effect; probably want one or the other.
Text editor powered by tinymce.