Hi i'm sorry if this has already been answered.

Hi i’m sorry if this has already been answered. I am struggling to find answers in this forum or on google. I have my WS2812B strip wrapped around the edge of a pool table. I want to have the animations start at the corner of the pool table but that is not where the strip starts. I think the easiest conceptual way of doing this is to have the beginning of the leds array to start at a different position other than 0.

Basically lets say the corner of the table is at leds[400] so I would like leds[0] to map to led number 400 and leds[1] map to led 401 and so on. Is there an easy way to either change the starting position of the leds array or shift the values in leds to a new array.

I hope this question makes sense. and somebody can point me in the right direction. Thank you

Here’s one way. Try something like this in your loop for testing and checking your offset:

for (uint16_t i=0; i<NUM_LEDS; i++) {
leds[(i+400) % NUM_LEDS] = CRGB:Green;
FastLED.show();
delay(100);
}
FastLED.clear();

Here’s info on modulo (%) if you haven’t seen it before.
https://www.arduino.cc/en/Reference/Modulo

Looking forward to photos/video of this pool table when you have it worked out. :slight_smile:

Another option (that uses a bit more memory) is to use a second array that you copy your leds data to with the offset before displaying. Here’s some example code:

@marmil ​ is right, the best way is to use modulo, once to get your head round how it works and the syntax it’s really useful…

Thanks for the quick responses guys! Thats really quick turn around.

The way I ended up doing it was creating a method called

int getRealPosition(int i){
if(i >= 88){
return i - 88; //88 is the number of LEDs from
//the end of the strip
}
return startPos+i; //startPos = NUM_LEDS-88
}

Now I call leds[getRealPosition(i)] = CRGB::Blue;

I may still try using modulo just for some more practice with it.