#include <FastLED.h>
#define NUM_LEDS 10
#define LED_PIN 16
#define DELAY_TIME 100 // Delay time in milliseconds
#define BLINK_COUNT 10 // Number of times to blink
#define BUTTON_PIN 2 // Pin for the momentary button
#define BUTTON_PIN 15 // Pin for the momentary button
CRGB left[NUM_LEDS];
CRGB right[NUM_LEDS];
bool buttonPressed = false;
void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(left, NUM_LEDS);
FastLED.addLeds<WS2812, LED_PIN, GRB>(right, NUM_LEDS);
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set button pin as input with internal pull-up resistor
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW && !buttonPressed) {
buttonPressed = true;
// Turn all left off
fill_solid(left, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(DELAY_TIME);
// Sequentially turn on each LED with amber color
for (int i = 0; i < NUM_LEDS; i++) {
left[i] = CRGB(255, 191, 0); // Amber color
FastLED.show();
delay(DELAY_TIME);
}
// Blink 10 times
for (int count = 0; count < BLINK_COUNT; count++) {
fill_solid(left, NUM_LEDS, CRGB(255, 191, 0)); // Amber color
FastLED.show();
delay(DELAY_TIME);
fill_solid(left, NUM_LEDS, CRGB::Black); // Turn off
FastLED.show();
delay(DELAY_TIME);
}
} else if (digitalRead(BUTTON_PIN) == HIGH && buttonPressed) {
buttonPressed = false;
}
}