I am working with NeoPixels through a yourduino.

I am working with NeoPixels through a yourduino. I am struggling to find a code that would blend specific colors and seamlessly move them down the string, almost like a rainbow cycle, but with no lines or breaks in the color just gradations.

Stuff like this is more easily achieved using HSV rather than RGB. I’m new to FastLED myself but do have a lot of experience with pattern writing. I have two workhorse functions - GetRGBfromHSV and GetHSVfromRGB which are invaluable for stuff like this. It is much easier to shift the hue from, say, red to blue with HSV adjustment than RGB. I’m sure others can chip in with appropriate FastLED code.

I’d do it this way: set up a palette with just the colors you want in it, and then use fill_palette to fill the led array with smoothly blended colors from the palette. Off the top of my head, I’d start with something like:

// Set up a palette with a gradient of colors
// from Red to Blue and back to Red.
CHSVPalette16 myColors(
CHSV(HUE_RED, 255,255),
CHSV(HUE_BLUE,255,255),
CHSV(HUE_RED,255,255));

uint8_t startingColorIndex = 0;
void loop()
{
// move down the strip
startingColorIndex++;

fill_palette(leds, NUM_LEDS,
startingColorIndex, 5,
myColors, 255, BLEND);

FastLED.show();
}

The one non-obvious ‘trick’ that this code is using is that the CHSVPalette16 has a constructor that automatically fills the 16-entry color array in the CHSVPalette16 with a ‘gradient’ of colors – all you have to do is specify what they are. In this case, I specified a gradient from Red to Blue and back again. There are these automatic-gradient-ctors on CHSVPalette16 for up to four colors. If you have more than that, there’s no ‘auto-gradient’ ctor for the palette, and you’ll have to specify all 16 colors for the palette by hand. See the Palette examples that come with FastLED for more illustrations on how to set up your palette.

Also there’s that number “5” sitting there in the call to fill_palette; adjusting that will control how densely the color stripes are on your LED strip. High number = more dense, lower number = less dense.

Try it, and let us know what you find!

@Mark_Kriegsman Exactly the kind of sample I was looking for yesterday… .Thanks! :slight_smile:

Also, if you want it to be more ‘stripes of color’ than a range of blended colors, set up the palette more like this, with explicitly colors for all 16 slots. It’ll still interpolate between colors where they meet, but this will appear more like stripes:

CHSVPalette16 myColors(
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 255,255),

            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 255,255), 

            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 

            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255) );

You can, of course, make the stripes narrower or wider, or add a dividing color (e.g. black) between them, or whatever you like. This palette (below) has denser stripes with black dividers between them.

CHSVPalette16 myColors(
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 255,255),
CHSV(HUE_RED, 0, 0), // Black

            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE, 0, 0), //Black 

            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 255,255), 
            CHSV(HUE_RED, 0, 0), // Black

            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE,255,255), 
            CHSV(HUE_BLUE, 0, 0)  //Black 

);

One of the great things about working with palettes is how easy it is to manually map, review, and edit out any sequence of colors you like.

@Mark_Kriegsman Thanks. Think that’ll be more than enough to get me started with this. Reminds me of the old days were I created palettes in dpaint II and cycled through them in turbo pascal :smiley:

Have you checked out FadeCandy? It’s a special purpose dithering controller for smart pixels that can be driven by anything from a Pi to a PC. It does a lot of the heavy lifting for the scenario you describe, and supports eight channels of up to 64 pixels each. You can attach multiple FadeCandy boards to a single server, which runs a lightweight server that accepts websocket connections, allowing for some really cool interactive possibilities. Adafruit has them for $27.

Love the FadeCandy!

It’s great if you want your animation to actually run on a PC of some sort (incl a RPi). But you can’t really use FadeCandy if you want your animations to run on the microcontroller itself.

It’s great for what it is and lots of people (including I) like it!

Mark took the original code you sent for just the fade and not the stripes and everything seems to be working and I will have picture up soon of what I am doing. thanks so much for helping, this sculpture is gonna fucking rock!!