I'm looking to combine two LED Effect scripts.
1st effect = sparkle for a determined amount of time then stop.
after the first effect stops, wait a determined amount of time then run;
2nd effect = strobe for a determined amount of time then stop
I have both codes but cant figure out how to combine them and how to handle the timing.. Any help would be appreciated.
Here is the Sparkle effect Script:
#include "FastLED.h"
#define LEDPIN 6
#define LED_TYPE NEOPIXEL
#define NUM_LEDS 450 // Number of RGB LEDs in the strand
#define BRIGHTNESS 5000
#define FRAMES_PER_SECOND 100 //higher equals faster
CRGB leds[NUM_LEDS];
void setup() {
// set up LED strip info
FastLED.addLeds<LED_TYPE,LEDPIN>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
fadeToBlackBy( leds, NUM_LEDS,3); //speed higher = faster
addGlitter(105); //lower equal faster
FastLED.show();
}
void addGlitter( fract8 chanceOfGlitter) {
if( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;}
}
This is the Strobe effect Script:
#include "FastLED.h"
#define NUM_LEDS 450
CRGB leds[NUM_LEDS];
#define PIN 6
void setup1 ()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
// REPLACE FROM HERE
void loop1() {
// Slower:
// Strobe(0xff, 0x77, 0x00, 10, 100, 1000);
// Fast:
Strobe(0xff, 0xff, 0xff, 10, 50, 1000);
}
void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
for(int j = 0; j < StrobeCount; j++) {
setAll(red,green,blue);
showStrip();
delay(FlashDelay);
setAll(0,0,0);
showStrip();
delay(FlashDelay);
}
delay(EndPause);
}
// REPLACE TO HERE
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}