So I've been learning arduino on the fly (mostly thanks to you guys!) and I've been working on a little led strip timer. Basically it needs to turn off 1 led in the array every 1 minute. But because it is supposed to be like a fire going out, I thought it would be cool to have the leds flicker (blink) like a flame does. So I learned about using millis() instead of delay and got the leds to flicker. I was super excited and after awhile managed to set up another timer in the same loop to turn off one led every minute. But that's where I'm stumped. It is turning off every light in both arrays instead of one light at a time per loop.
So basically I want: Ten leds on the strip to flicker (blink quickly), then one of those ten to turn off every time a minute passes, until ten mins is up. Then I figure I'd end with some leds turning red to show the timer has ended, but I haven't gotten that far, as I've been stumped on the 2nd step for hours.
Is what I'm trying to do possible? I know I could just write out each led with its own 1 minute timer, but that would be pretty huge, and you guys always talk about how if you're repeating the same code over and over you're doing something wrong.
Here's the code, any help is really appreciated. Thanks!
#include <FastLED.h>
#define NUM_LEDS 50
#define DATA_PIN 6
#define BRIGHTNESS 10
#define COLOR_ORDER RGB
CRGB leds[NUM_LEDS];
int color;
int flicker1[] ={2, 8, 17, 20, 26};
int flicker2[] ={5, 11, 14, 23, 29};
void setup() {
delay(2000);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop()
{
for (int i = 0; i < 5; i++) {
unsigned long startTime;
unsigned long interval = 6000;
static unsigned long lastMillis = 0;
static bool toggle = false;
if(millis() - lastMillis > 13UL)
{
if(toggle)
{
//show colorA
leds[flicker1[i]] = CRGB(255,50,0);
leds[flicker2[i]] = CRGB(30,10,0);
}
else
{
leds[flicker1[i]] = CRGB(30,10,0);
leds[flicker2[i]] = CRGB(255,50,0);
}
if (millis() - startTime >= interval)
{
leds[flicker1[i]] = CRGB(0,0,0);
leds[flicker2[i]] = CRGB(0,0,0);
}
toggle = !toggle;
lastMillis = millis();
FastLED.show();
}
}
}