Hello there.
First time posting after reading the forums a fair bit.
New-ish coder here, a bit rusty after taking a couple decades off.
The goal of the code is to create a five color sequence of christmas colours, preferably using the BEAT8 function, so I can set the speed of the sequence. My brain likes wave functions. I'd also prefer to use the EVERY_N_MILLISECONDS function to set my timing between each colour. I tried inserting the EVERY_N_MILLISECOND function into the second band and it either duplicated the colour onto the same space as the first, or it had no effect.
The board I'm using is the Teensy 4.0 board and the LED strips are the 144 LED WS2812 strips, the NeoPixels.
The other stumbling block I ran into is when I set the code to run at 60 BPM or higher on the strips, I noticed an odd flickering before the leading color. I'd like it to look smoother. Possibly a framerate or timing issue?
Right! With that out of the way, here's the code.
#include <FastLED.h>
#define NUM_LEDS 60 //Supposed to be 144 LED's here, but 60 is in place to slow things down and to check spacing.
#define LED_PIN 1
#define FASTLED_ALLOW_INTERRUPTS 0
#define PULSE 15 //this sets how quick the LED's go from one end to the other in the strip. 15 is set so the sequence is easier to modify
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB> (leds, NUM_LEDS).setCorrection(TypicalPixelString);
FastLED.setBrightness(10);
FastLED.setDither(0);
FastLED.clear();
}
void loop() {
uint8_t leader1 = map(beat8(PULSE,0), 0, 256, 0, NUM_LEDS +6); //This is the first color in a sequence of five. 'Leader' is the keyword for the first band. Second color band is block 1, third is block 2, and so on
uint8_t leader2 = map(beat8(PULSE,0), 10, 256, 0, NUM_LEDS +3);
uint8_t leader3 = map(beat8(PULSE,0), 20, 256, 0, NUM_LEDS);
leds[leader1] = CRGB(23,117,28);
leds[leader2] = CRGB(23,117,28);
leds[leader3] = CRGB(23,117,28);
fadeToBlackBy(leds, NUM_LEDS, 20);
FastLED.show();
}
To sum up: How do I time it so that the other four colors show up in the sequence, and how do I negate any flickering?