Hi, I'm using a 144 Neopixel strip with an Arduino Nano.

Hi,

I’m using a 144 Neopixel strip with an Arduino Nano. I have the library up and running (it’s amazing!) but have hit a stumbling block with what I want to do.

The effect I’m trying to achieve is a particle which I can move up and down the led strip and vary its size. The way I thought of doing this was to specify a target pixel and a size. For example I might have an array like this: [pos, size]. With the array set as [6, 2], pixel 6 and two pixels either side would light ( pixel 3,4,5,6,7 would be lit). I’d then be able to move the ‘particle’ around and change it’s size by modifying these variables. I’d then interpolate colour values from the target pixel to the size variable left and the same for right. I can do all this, but the problem I have is ‘wrapping’. For example when I move the particle to the end of the strip, pixels will ‘fall off’ and I can’t get them to wrap around to the beginning of the strip. I experimented with modulo but with no luck.

So I guess my questions are, am I approaching this in the right way? Is there something in the library that might make it easier for me to do this? If the way I’ve explained is a reasonable way for me to do this, how can I wrap the pixels that fall off?

Thanks in advance for any advice.

For wrapping, you might be interested in:

https://github.com/atuline/FastLED-Demos/blob/master/ripple/ripple.ino

Awesome, thanks! I’ll have a look.

I’ve done something like this when I needed wrapping that could go both directions:
leds[(position + delta + NUM_LEDS) % NUM_LEDS] = CRGB::White;

By adding NUM_LEDS to the position + delta before doing the modulo it covers the case where a negative delta has the wrap going backwards. So for your setup I think it could be something like:

for (int delta = 0; delta <= size; i++) {
leds[(pos + delta + NUM_LEDS) % NUM_LEDS] = CRGB::White;
leds[(pos - delta + NUM_LEDS) % NUM_LEDS] = CRGB::White;
}
FastLED.show();

Have changed my code over to Marc’s.

Just tried out your code Marc. It works!.. but it seems to be very laggy when driving 144 pixels… I’m guessing when driving this many pixels this code hogs quite a bit of resources?

Whoops had an error in my code, it’s working nice and fast now, thanks guys!

Excellent. Share a youtube video if you can, I’d enjoy seeing it.

Very early stages of the project but you can see the above code working at least! https://vine.co/v/eHHMj3ggtAK