I'm trying to use a 60 WS2812 led ring with repeating patterns as follows
6 White led's rotating around the ring for 5 minutes
changing to 4 Red led's rotating around the ring at increasing speed for 10 seconds
Then the 60 led's flashing red 5 times
rinse and repeat
My latest adventure, butchering this code from Marc Miller.
It's somewhere close but the white led's pause at the end of each rotation and I've not worked out how to speed up the red led's rotation
// EVERY_N trigger timer and variable timer example
//
// Using EVERY_N with a timer check to always run "Event B" at
// a specific time after "Event A".
//
// Also, an example of using EVERY_N with a random variable time.
//
// Marc Miller, May 2016
//---------------------------------------------------------------
#include "FastLED.h"
#define LED_TYPE WS2812
#define DATA_PIN 4
//#define CLOCK_PIN 13
#define NUM_LEDS 60
#define COLOR_ORDER RBG
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];
uint16_t timerA = 3000; // How often to run Event A [milliseconds]
uint16_t timerB = 500; // How long after A to run Event B [milliseconds]
boolean counterTriggered = 0; // Event triggered? [1=true, 0=false]
//---------------------------------------------------------------
void setup() {
// Serial.begin(115200); // Allows serial output (check baud rate)
delay(1500); // 3 second startup delay
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
//---------------------------------------------------------------
void loop() {
// Setting the amount of time for "triggerTimer".
// You can name "triggerTimer" whatever you want.
static CEveryNMilliseconds triggerTimer(timerB);
EVERY_N_MILLISECONDS(timerA){
EVERY_N_SECONDS_I( timingObj, 50)// delay for white
// do Event A stuff
for(int i=0;i<NUM_LEDS;i++){
leds[i-4].setRGB(0,0,0);
leds[i].setRGB(0,0,255);
FastLED.show();
delay(90);
}
// counterTriggered = 1; // Set to True
// triggerTimer.reset(); // Start trigger timer
FastLED.clear();
}
EVERY_N_MILLISECONDS(timerA){
EVERY_N_SECONDS_I( timingObj, 50)// delay for white
// do Event A stuff
for(int i=0;i<NUM_LEDS;i++){
leds[i-4].setRGB(0,0,0);
leds[i].setRGB(0,0,255);
FastLED.show();
delay(60);
}
counterTriggered = 1; // Set to True
triggerTimer.reset(); // Start trigger timer
FastLED.clear();
}
if (counterTriggered == 1) { // Will only be True if Event A has started
if (triggerTimer) { // Check if triggerTimer time reached
// EVERY_N_SECONDS_I( timingObj, 5)
// do Event B stuff
for(int i=0;i<NUM_LEDS;i++){
leds[i-6].setRGB(0,0,0);
leds[i].setRGB(255,255,255);
FastLED.show();
delay(80);
}
// counterTriggered = 0; // Set back to False
// triggerTimer.reset(); // Start trigger timer
FastLED.clear();
FastLED.clear();
// delay(80);
}
}
/*
EVERY_N_SECONDS_I( timingObj, 20) {
// This initally defaults to 20 seconds, but then will change the run
// period to a new random number of seconds from 10 and 30 seconds.
// You can name "timingObj" whatever you want.
timingObj.setPeriod( random8(10,31) );
FastLED.clear();
for (uint16_t i=0; i<NUM_LEDS*3; i++){
leds[random8(NUM_LEDS)] = CRGB::Black;
leds[random8(NUM_LEDS)] = CHSV(random8(), random8(140,255), random8(50,255));
FastLED.show();
delay(random8(20,80));
}
delay(500);
}
*/
// FastLED.show();
}//end main loop