Back to Parent

void loop() {

    if (timeStarter == true){
        
        long timeNow = millis();
        long timeElapsed = timeNow - timeStartedAt;
        int r = 255;
        int g = 255;
        int b = 255;
        
        if (timeElapsed < durationOfFade){
            int colorValue = map(timeElapsed, 0, durationOfFade, 0, 255);
            
            for (int i = 0; i < strip.numPixels(); i++){
                strip.setPixelColor (i, r, g - colorValue, b - colorValue);
            }
            strip.show();
            delay (10);
        }else if ( ((durationOfFade - timeElapsed) > 0) && ((durationOfFade - timeElapsed) < 1000*10)){

            for (int i = 0; i < strip.numPixels(); i++){
                strip.setPixelColor (i, 255, 0, 0);
            }
            strip.show();
            delay (100);   
            
            for (int i = 0; i < strip.numPixels(); i++){
                strip.setPixelColor (i, 0, 0, 0);
            }
            strip.show();
            delay (100);     
        
        } else {
            for (int i = 0; i < strip.numPixels(); i++){
                strip.setPixelColor (i, 0, 0, 0);
            }
            strip.show();
            delay (100);                     
        }
        
        Serial.println ((durationOfFade - timeElapsed));
        delay(1000);
    }
    
    
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0