FASTLED, WS2811 - How to set static rainbow pattern


I have a set of WS2811 LED's hooked up to a Uno.

I've been playing with examples using the Fastled library and had numerous patterns running up and down the string.

What I would like to do is simply display a static, repeating rainbow, for the whole length of the string (Currently 20 LED on my test one, but more on order)

So LED1 = Red, LED2 = Orange, LED3=Yellow, LED4=Green, LED5=Blue, LED6=Indigo, LED7=Violet, LED8=Red etc

Whats the simplest way to do this?

This will end up being one of a number of sequences that I create for my lights.

Try this:

for (int i=0; i<20; i++)
  leds[i] = CHSV( map(i % 7, 0, 7, 0, 255), 255, 255);

Thats a great starting point, thanks :slight_smile:

Two of the Blue's are very similar (LED5 & LED6), so I will have a go at tweaking it.

I wonder if the CHSV() function uses "Spectrum" or "Rainbow"? The Spectrum one has a wider range of angles that I would call blue. EDIT: according to this page, it uses the Rainbow.

The code above will use hue angles 0, 36, 73, 109, 146, 182, 229

for (int i=0; i<20; i++)
  hsv2rgb_spectrum(CHSV( map(i % 7, 0, 7, 0, 255), 255, 255), leds[i]);

Thank you for the amended code.

I tried this, again LED 5 & 6 are very similar colours.

This is a 20 LED strip of WS2811 in 30mm opaque domes. Perhaps its a feature of this that makes them look similar?
All other colours are perfect.

I end up with:-
Pale blue

LED 5 & 6 are very similar colours

They would have hue angles of 146 & 182, which are in the blue part of both those above charts. I don’t think it’s because of the type of LEDs you have, its the groups of 7.

If you coloured the LEDs in groups of 8 instead of 7, I think it would be better:

for (int i=0; i<20; i++)
  leds[i] = CHSV( map(i % 8, 0, 8, 0, 255), 255, 255);

That is better, thank you. The colours are now more varied :slight_smile: