I'm having an issue with trying to make a string of lights chase each

I’m having an issue with trying to make a string of lights chase each other. I seem to be hitting a limit of around 22 (depends on configuration). If I go one over the “limit” the refresh rate slows to a crawl. Two over and it doesn’t show anything on the string. Variable in question is “width”.

#include <FastLED.h>

const byte maxConsecLEDS = 30;
#define NUM_LEDS 144
#define DATA_PIN 6
CRGB leds[NUM_LEDS+maxConsecLEDS];

void setup()
{
FastLED.clear();
Serial.begin(9600);
FastLED.addLeds<WS2812B, DATA_PIN>(leds, NUM_LEDS);
LEDS.setBrightness(100);

}

void loop()
{

int width = 22;
FastLED.clear();
int hue = 0;

for (int dot = 0; dot < NUM_LEDS + width; dot++) {
	 hue = map(dot, 0, NUM_LEDS, 0, 255);

	leds[dot].setHSV(hue, 255, 100);

	leds[dot - width] = CHSV(0, 0, 0);

	FastLED.show();

	Serial.print(dot);
	Serial.print("   ");
	Serial.println(hue);
	delay(25);
}

Serial.println();
Serial.println();

for (int dot = NUM_LEDS; dot > 0 - width; dot--) {
	hue = map(dot, 0, NUM_LEDS, 0, 255);

	leds[dot].setHSV(hue, 255, 100);

	leds[dot + width] = CHSV(0, 0, 0);

	FastLED.show();

	Serial.print(dot);
	Serial.print("   ");
	Serial.println(hue);
	delay(25);

}

}

Having FastLED.show() and the delay inside your for loops is unnecessarily and can slow things down. Pull those out of the for loops and put them just after the loop. You don’t need to run show() after updating each individual pixel. Update all pixels that need updating and then run show().

Also, having lots of print statements in loops slows things down too. (It does actually take a a bit of time and that all adds up to print out a bunch of stuff to the serial monitor.) Use those print statements for debugging, but then comment them out to make sure things run as fast as possible.

Also, if you try to address a pixel number that is beyond the number of pixels you’ve defined for NUM_LEDS that will cause problems. So in your loop you have NUM_LEDS+width and if width is anything larger then 0 then thing are going to start getting funky since dot in leds[dot] will be greater then NUM_LEDS-1.

Here’s a marquee example I made a while back which you might like.

Here’s another simple example which might be interesting.