// https://wokwi.com/projects/438176050010628097
# include <FastLED.h>
# define NUM_LEDS 299
# define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
# define PRESSED LOW
# define DATA_PIN 4
# define theButton 2
void setup() {
Serial.begin(115200);
Serial.println("\nThis is actually painful.\n");
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(255); // 84 = dim
pinMode(theButton, INPUT_PULLUP);
}
void loop() {
if (digitalRead(theButton) == PRESSED) {
Serial.print("cycle intitiated...");
Serial.flush();
runSAMD21();
Serial.println(" ... and complete.");
}
}
void setLedColor(int colorStep)
{
int r = colorStep;
int b = 255 - colorStep;
int g = 0;
for(int x = 0; x < NUM_LEDS; x++)
leds[x] = CRGB(r, g, b);
FastLED.show();
}
void runSAMD21() {
for (int colorStep = 0; colorStep < 256; colorStep++)
setLedColor (colorStep);
for (int colorStep = 255; colorStep > -1; colorStep--)
setLedColor (colorStep);
}