Hello. I've been trying this for a while and just can't get it to work no matter how I write the code. I want my twinkle program to run for around 3 minutes then loop into my fade program, that will run for 30 seconds. It should be easy, right. I must be missing something. Here are the codes I want to combine
Twinkle
#include <FastLED.h> // FastLED library
#define datapin 4 // Data pin
#define NUM_LEDS 30 // Number of LED's
#define COLOR_ORDER GRB // Change the order as necessary
#define LED_TYPE WS2812B // What kind of strip are you using?
#define BRIGHTNESS 196 // How bright do we want to go
struct CRGB ledsA[NUM_LEDS]; // Initializxe our array
// Initialize global variables for sequences
int thisdelay = 8; // A delay value for the sequence(s)
void setup(){
LEDS.setBrightness(255);
LEDS.addLeds<WS2812B, datapin, GRB>(ledsA, NUM_LEDS);
memset(ledsA, 0, NUM_LEDS * sizeof(struct CRGB));
}
unsigned long functionDuration = 10*60UL;//30*60000UL;
unsigned long cycleStart;
int state;
void loop () {
twinkle();
}
void twinkle() {
int i = random8(); // A random number. Higher number => fewer twinkles. Use random16() for values >255.
if (i < NUM_LEDS) ledsA[i] = CHSV(180, 234, 255); // Only the lowest probability twinkles will do. You could even randomize the hue/saturation. .
for (int j = 0; j < NUM_LEDS; j++) ledsA[j].fadeToBlackBy(8);
LEDS.show(); // Standard FastLED display
//show_at_max_brightness_for_power(); // Power managed FastLED display
delay(100); // Standard delay
//LEDS.delay(150); // FastLED delay
// delay_at_max_brightness_for_power(thisdelay); // Power managed FastLED delay
} // twinkle()
This is the Fade
void loop()
{
static uint8_t hue = 0;
for (int px = NUM_LEDS - 1; px > 0; px--)
{
leds[px] = leds[px - 1];
}
leds[0] = CHSV(hue++, 255, 255);
FastLED.show();
delay(10);
}
Thank you