How to run a sketch for a fixed amount of time from power-on

Hello all, I'm relatively new to Arduino programming and need just a little bit of help figuring an issue out: I'd like to make the following sketch (which blinks a set of Neopixels red rapidly for a fixed amount of time) run for 2 second after the Nano it is running on powers up, OR - since the blink time length is 2000ms anyway - how can I loop the sketch only once? I've tried several ideas without luck so if anyone can help I'd be very appreciative!

#include <WS2812FX.h>

#define LED_COUNT 18
#define LED_PIN 4

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

void loop() {

Loop runs all the time , setup only once .

If you want the sketch to only run once , you can put it all in setup()

Explain what happens when the time is up. An Arduino never stops your loop() part of your code.

the strip will blink rapidly for 2 seconds, pause for 1 second and the repeat. I tried putting ws2812fx.service into setup and still runs more than once.

You need to look more closely at how this library works. I’m not familiar with it , I’m guessing there must be another command you can send, afterwards, to stop the lights

I'm happy to accept another solution that will create the same effect! this is being used as a third brake light on a childs go-kart so the solution doesn't need to be pretty. all I want to happen is for the strip to blink for two seconds rapidly when power is applied to the Nano

It appears you send a command and the leds flash with the setting you have sent and carry on until you send another command . There must be a command to send to blank the leds out .
Have you looked through the library documents and provided examples