I don't remember where I found this but I like the way it looks.

I don’t remember where I found this but I like the way it looks. What would be the best way to keep the pattern doing the same thing and remove the delay? Trying to integrate a button to change variables but it won’t work because the delay is messing with the reading of the button. This is just the raw program without any button integration.

#include “FastLED.h”

// How many leds in your strip?
#define NUM_LEDS 120

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 10
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
Serial.begin(57600);
Serial.println(“resetting”);
LEDS.addLeds<WS2812B,DATA_PIN,GRB>(leds,NUM_LEDS);
LEDS.setBrightness(255);
}

void loop() {
static uint8_t hue = 0;
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i’th led to red
leds[i] = CHSV((hue++ + 20), 255, 255);
// Show the leds
FastLED.show();
// now that we’ve shown the leds, reset the i’th led to black
// leds[i] = CRGB::Black;
for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); }
// Wait a little bit before we loop around and do it again
delay(15);
}

// Now go in the other direction.  
for(int i = (NUM_LEDS); i >= 0; i--) {
	// Set the i'th led to red 
	leds[i] = CHSV((hue++ + 20), 255, 255);
	// Show the leds
	FastLED.show();
	// now that we've shown the leds, reset the i'th led to black
	// leds[i] = CRGB::Black;
 for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); }
	// Wait a little bit before we loop around and do it again
	delay(2);
}

}

This is sort of sudo code as I have no MCU with me to test it with…

I updated that code slightly.

I use something like this
unsigned long lastTick;

void setup()
{
lastTick=millis();
}

void wait(unsigned long period)
{
while(true)
{
unsigned long now=millis();
unsigned long delta=now-lastTick;
if(delta>=period)
{
lastTick=now;
return;
}
// do other stuff here
}
}