I'm fairly new to coding and am completely delighted with this library,

I’m fairly new to coding and am completely delighted with this library, so THANK YOU. I would love some help with a specific effect: I want a smooth gradient, very similar to the new_rainbow_loop effect in the sample code, but that just fades in a gradient between 2 and 3 colors – i.e. purple to blue and then back to purple again. I want a smooth transition like the new_rainbow_loop code has. I can’t figure out how to do this without going all the way through the rainbow. Any hints?

Here is a way I “clamped” the color to a specific range:

void new_rainbow_loop(){
ihue = 160;
while (ihue < 192) {
ihue++;
fill_rainbow( leds, LED_COUNT, ihue );
LEDS.show();
delay(6);
}
while (ihue > 160) {
ihue–;
fill_rainbow( leds, LED_COUNT, ihue );
LEDS.show();
delay(6);
}
}

That’s a little closer… but it still shows the whole spectrum instead of just 2 colors. I’ve tried tweaking all the parameters and can’t seem to get it to just show purple and blue. I’ve got 28 LEDs in my strip, if that helps…

I just edited the post above. Can you re-try the edited code and see if that works?

// Each call to this function does one frame of the loop. Makes a rolling
// wave of color between the minimum hue and the maximum hue.
// Speed determines how fast the wave moves along the strip.
// wavespeed determines how many times you will cycle through colors
// in a single frame.
//
// minHue - one side of the hue range
// maxHue - the other side of the hue range
// speed - how fast the base hue should move/change for the first led
// wavespeed - how fast the hue changes from led to led
void new_wave_loop(uint8_t minHue, uint8_t maxHue, int speed, int wavespeed) {
static uint16_t sinBase = 0;

// save the current sinBase to have something to modify/walk forward with
// in this frame
uint16_t sinCurrent = sinBase;

for(int i = 0; i < NUM_LEDS; i++) {
int work = sin16(sinCurrent);
uint8_t hue = map(work,-32767,32767,minHue,maxHue);
leds[i] = CHSV(hue, 255,255);
sinCurrent += wavespeed;
}

sinBase += speed;
LEDS.show();
}

void loop() {
new_wave_loop(150, 225, 100, 3303);
delay(10);
}

Basically, the code above is using a sin wave to cycle your values between 160 and 192 and back again, smoothly. (The map isn’t the most efficient way to do this, but it keeps the code pretty straightforward here).

(N.B. - I haven’t tried running the above code yet - juggling some setup stuff here at the moment)

And I just updated the comment to code that I actually have running/working here - there were some minor typos in there that would make what I originally pasted in not work terribly well :slight_smile:

It tells me: too few arguments to function ‘void new_wave_loop(uint8_t, uint8, t, int, int)’

oh wait that’s because I set it up wrong.

THAT IS BEAUTIFUL. And I love how both solutions give me a similar yet different effect. Thank you so much!!! (gonna post project pics really really soon… right now my project is completely blowing me away)