I’m trying to biuild a countdown timer with 12 WS2812 ring. Initial code using Delay() worked Ok but now trying using millis() based on the BlinkWithout Delay tutorial. I want an action at n millis intervals and the logic works eg I can get a message “Yes” to the serial monitor every n millis (i’ll develop the code for the countdown whn i gert this working) but when I add fast LED code I cannot get the LEDS to run the two colourschemes at the same n millis. When I upload it the 1st LED glows brighly and some but not all the rest illuminatee but there is no change between the two states despite the serial message responding correclty. Not sure if I shoul post code here but here goes: All help greatefully received
#include <FastLED.h>
#define NUM_LEDS 12
#define DATA_PIN 1
CRGB leds[NUM_LEDS];
unsigned long StartMillis(millis());
unsigned long LED_On(2000);
unsigned long CurrentMillis;
int counter;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setBrightness (32);
StartMillis = millis();
Serial.begin(9600);
Serial.println(StartMillis);
}
void loop() {
CurrentMillis = millis();
Serial.print(“Start”);
Serial.println(StartMillis);
Serial.println(“Current”);
Serial.println(CurrentMillis);
if(CurrentMillis-StartMillis >= LED_On * counter)
{
Serial.println(“Yes”);
//set LED colourscheme
leds[0] = CRGB::Black;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Black;
leds[5] = CRGB::Yellow;
leds[6] = CRGB::Yellow;
leds[7] = CRGB::Black;
leds[8] = CRGB::Green;
leds[9] = CRGB::Green;
leds[10]= CRGB::Green;
leds[11]= CRGB::Green;
FastLED.show(); //turn on all LEDS
delay(2000);
Serial.println(“Yes”);
//Serial.println(CurrentMillis-StartMillis);
counter = counter +1;
}
}