How do I Turn on 3 Led strips at different times?

Hello everyone, I am new to Arduino and don't know pretty much anything. I wanted to know if there was a way to turn on 3 different led strips at different times each with a chase function. I have a script that I like, but just want to add some sort of delay before the other strips starts chasing. (example) strip one starts, then 2 seconds later strip 2 starts then 1 seconds later strip 3 starts.

Any help would be apricated!

#include <Adafruit_NeoPixel.h>

#define NUM_STRIPS  3
#define N_LEDS      144

//data pins for the strips
const uint8_t   pinS1 = 6;
const uint8_t   pinS2 = 7;
const uint8_t   pinS3 = 8;

//create the strips
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel( N_LEDS, pinS1, NEO_GRB + NEO_KHZ800 );
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel( N_LEDS, pinS2, NEO_GRB + NEO_KHZ800 );
Adafruit_NeoPixel strip3 = Adafruit_NeoPixel( N_LEDS, pinS3, NEO_GRB + NEO_KHZ800 );

//create a handy array of strip objects
Adafruit_NeoPixel *grStripIDs[NUM_STRIPS] = 
{
    (Adafruit_NeoPixel *)&strip1,
    (Adafruit_NeoPixel *)&strip2,
    (Adafruit_NeoPixel *)&strip3
    
};

//per-strip delays
const uint32_t grDelays[NUM_STRIPS] = {10ul, 25ul, 75ul};
//per strip colors
const uint32_t grColors[NUM_STRIPS] = {0x00ff0000, 0x0000ff00, 0x000000ff};

//a structure carrying each strips' information
typedef struct structStrips
{
    Adafruit_NeoPixel   *strip;         //pointer to the strip
    uint32_t            timeStrip;      //time keeping for the strip delay
    uint32_t            timeDelay;      //the strip delay
    uint32_t            sColor;         //the strip color
    uint16_t            index;          //the LED index on the strip
}sStrips_t;

sStrips_t grStrips[NUM_STRIPS];

void setup( void )
{
    //grab the time
    uint32_t tNow = millis();
    //initialize the strips
    for( uint8_t i=0; i<NUM_STRIPS; i++ )
    {
        grStrips[i].strip = grStripIDs[i];      //get a pointer to this strip
        grStrips[i].sColor = grColors[i];       //set its color
        grStrips[i].timeDelay = grDelays[i];    //set its delay
        grStrips[i].timeStrip = tNow;           //initialize its timer
        grStrips[i].index = 0;                  //start all at LED index zero

        grStrips[i].strip->begin();             //and begin
        
    }//for
       
}//setup

void loop( void )
{
    chase();
    
}//loop

void chase( void )
{
    static uint8_t
        stripIndex = 0;     //index for which strip we operate on each pass
    uint32_t
        tNow = millis();    //current time (millis count)

    //has this strip's delay timed out?
    if( (tNow - grStrips[stripIndex].timeDelay) >= grStrips[stripIndex].timeStrip )
    {
        //yes; save the time for the next delay
        grStrips[stripIndex].timeDelay = tNow;

        //set and clear the pixels as before
        grStrips[stripIndex].strip->setPixelColor( grStrips[stripIndex].index, grStrips[stripIndex].sColor );
        grStrips[stripIndex].strip->setPixelColor( grStrips[stripIndex].index-15, 0 );
        //and update the strip
        grStrips[stripIndex].strip->show();

        //bump the pixel index for this strip
        grStrips[stripIndex].index++;
        if( grStrips[stripIndex].index >= (grStrips[stripIndex].strip->numPixels()+4) ) //similar to ">= strip.numPixels()+4"
            grStrips[stripIndex].index = 0; //if so, start over
        
    }//if

    //each pass we look at a different strip so no one strip delays and holds up any others
    stripIndex++;
    //once we finish the last strip, cycle back to the first again
    if( stripIndex == NUM_STRIPS )
        stripIndex = 0;
        
}//chase

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.