// https://www.reddit.com/r/FastLED/comments/zdqvtq/pausing_beatsin16_at_0_and_resuming_from_0/
#include <FastLED.h>
#define NUM_LEDS 28
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, 3, GRB>(leds, NUM_LEDS);
}
void loop() {
static uint32_t paused = 0;
static uint32_t timebase = 0;
static uint16_t lead_dot = 0;
uint16_t prev_dot = lead_dot;
if (!paused) {
lead_dot = beatsin16(34, 0, NUM_LEDS - 1, timebase, 0);
}
fadeToBlackBy(leds, NUM_LEDS, 2);
leds[lead_dot] = ColorFromPalette(RainbowColors_p, millis() / 8, 255, LINEARBLEND);
FastLED.show();
// when we reach 0, pause and take a note of the timestamp
if (lead_dot == 0 && prev_dot != 0 && !paused) {
paused = millis();
}
// when un-pausing, add the paused time to timebase to move the 0 to the present moment
if (paused && millis() - paused >= 500) {
timebase += millis() - paused;
paused = 0;
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
neopixels1:DOUT
neopixels1:VDD
neopixels1:VSS
neopixels1:DIN