RGB cycle effects on custom RGB panels with WS2812b strip

Hey guys, I´m struggling a bit with the following project:

I have created 5 RGB panels out of wood and I attached an LED strip to the panels. I will definitely add a scheme of how this looks, because it´s a bit hard to explain. (please excuse my bad painting skills, I hope you can understand how it´s built :D)

Each panel contains multiple parts of the LED strip as it runs at least two times through every panel.

My plan was to let every panel have it´s own rainbow cycle but with a small delay which is different from panel to panel (so that the cycle will always be in a different status than the cycle of the panel next to it).

My current problem is the color cycle effect. I have tried to use the Adafruit default RGB cycle effect(I think this is the coolest) but I dont know how to run it on every single array I created(to devide the strip into the panels, but maybe this isnt the best solution either, I`d appreciate other ideas as well).

#include "FastLED.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> 
#endif
#define PIN         6
#define NUM_LEDS    40
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB

Adafruit_NeoPixel strip(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);






byte array1[] = { 0,  1,  2,  3,  36, 37, 38, 39 };
byte array2[] = { 4,  5,  6,  7,   8, 33, 34, 35 };
byte array3[] = { 9, 10, 11, 12,  29, 30, 31, 32 };
byte array4[] = {13, 14, 23, 24,  25, 26, 27, 28 };
byte array5[] = {15, 16, 17, 18,  19, 20, 21, 22 };
                                                
void setup() 
{
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
    clock_prescale_set(clock_div_1);
  #endif
  strip.begin();           
  strip.show();          
  strip.setBrightness(50);

}



void loop() 
{
  for (int i = 0; i < 9; i++)
  {
    for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) 
    {
      for(int i=0; i < 9; i++) 
      {
        int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
        strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
      }
    }
  }
  delay(60);


  
  for (int i = 0; i < 9; i++)
  {

  }
  delay(60);

  
  for (int i = 0; i < 9; i++)
  {

  }
  delay(60);

  
  for (int i = 0; i < 9; i++)
  {

  }
  delay(60);
  
  
  for (int i = 0; i < 9; i++)
  {

  }
  FastLED.show();
  delay(60);



}

I hope you can understand the problem and help me with it.
If anything isn`t clear to you, I will add more Information.

If you are going to run the same effect on every panel, it would be a bit simpler to use a two dimensional array, then you can use nested if statements to cycle through each panel, then each pixel within that panel.

Delaying the effect on each panel can be accomplished by adding an offset to the pixelHue value for each panel's pixels.

The multiple delay() statements are unnecessary - one will be sufficient, because you are changing the color of all the pixels before you update the actual LEDs.

Using both the FastLED and Adafruit_NeoPixel libraries may cause problems, would be better to do everything with a single library.

Using both the FastLED and Adafruit_NeoPixel libraries may cause problems, would be better to do everything with a single library.

Yikes, agreed. Like putting petrol and diesel in the same engine! But the OP does not actually seem to be using FastLED library, so
#include "FastLED.h" can be removed from the sketch.

Thanks for the input guys. You are right, one library is enough, I removed the FastLED library.

The idea with the two dimensional array sounds very promising but this is actually my first time using them in a sketch.
@david_2018 maybe you have an example or a suggestion how I could achieve the RGB effect on each panel?

This is my current code:

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> 
#endif
#define PIN         6
#define NUM_LEDS    40
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB

Adafruit_NeoPixel strip(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);


int ledarray[5][8] = {
  { 0,  1,  2,  3,  36, 37, 38, 39 }, 
  { 4,  5,  6,  7,   8, 33, 34, 35 }, 
  { 9, 10, 11, 12,  29, 30, 31, 32 }, 
  {13, 14, 23, 24,  25, 26, 27, 28 }, 
  {15, 16, 17, 18,  19, 20, 21, 22 }
};

void setup() 
{
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
    clock_prescale_set(clock_div_1);
  #endif
  strip.begin();           
  strip.show();          
  strip.setBrightness(50);
}



void loop() 
{
  for (int i = 0; i < 9; i++)
  {
    for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) 
    {
      for(int i=0; i < 9; i++) 
      {
        int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
        strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
      }
    }
  }
}
void loop() 
{
  for (int i = 0; i < 9; i++)
  {
    for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) 
    {
      for(int i=0; i < 9; i++) 
      {
        int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
        strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
      }
    }
  }
}

You left out the strip.show() command to update the LED strip.

The for statements have a couple of problems, the first is that you are presumably referring to the 8-element array, so the array elements are numbered 0 through 7, not 0 through 8. The other problem is that it is generally bad to have nested for statements that declare variables with the same name ( i in this case). The variable is local to the for statement that created it, so the code can get a bit confusing as to which i you are referring to.

The strip.setPixelColor() statement shouldn't be setting the color of led i, it needs to reference the led number from your array.

Have a look at this and see how it handles the array, it won't give you the staggered pattern for each panel, but should give the rainbow effect.

void loop() 
{
  for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
    for (byte p = 0; p < 5; p++) { //cycle through all 5 panels
      for (int i = 0; i < 8; i++) { //cycle through all 8 leds per panel
        int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
        strip.setPixelColor(ledarray[p][i], strip.gamma32(strip.ColorHSV(pixelHue)));
      }
    }
    strip.show();
    delay(10);
  }
}