I have these two sketches made for my addressable LED strip that I would like to automatically switch back and forth.
The first "profile" (I don't know what to refer to these settings/profiles as) is this first bit of code. I would like for this to run for 4 minutes before switching to the next profile.
#include <FastLED.h>
#define LED_PIN 5
#define NUM_LEDS 12
#define BRIGHTNESS 255
#define LED_TYPE NEOPIXEL
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
/////////////////////////////
/////////// Speed ///////////
#define UPDATES_PER_SECOND 36
/////////////////////////////
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 Preset;
extern const TProgmemPalette16 Preset_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
currentPalette = Preset_p;
currentBlending = LINEARBLEND;
}
void loop()
{
static uint8_t startIndex = 0;
startIndex = startIndex + 1;
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
//////////////////////////////
uint8_t brightness = 255;
//////////////////////////////
for ( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
////////////////////////////////////////////////////////////
///////////////// Changes the width of each color //////////
colorIndex += 9;
////////////////////////////////////////////////////////////
}
}
const TProgmemPalette16 Preset_p PROGMEM =
{ ////////////////////
CRGB::Red,
CRGB::Red,
CRGB::Purple,
CRGB::Purple,
CRGB::Cyan,
CRGB::Cyan,
CRGB::Purple,
CRGB::Purple,
CRGB::Red,
CRGB::Red,
CRGB::Purple,
CRGB::Purple,
CRGB::Cyan,
CRGB::Cyan,
CRGB::Purple,
CRGB::Purple,
/////////////////////
};
Then the next profile I would like to run for just 1 minute, then switch back to the first, making a 5 minute loop.
#include "FastLED.h"
#define NUM_LEDS 12
#define DATA_PIN 5
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop()
{
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Red;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Red;
delay(25);
}
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Red;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Purple;
delay(25);
}
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Cyan;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Cyan;
delay(25);
}
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Cyan;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Purple;
delay(25);
}
}
Any help would be greatly appreciated!