#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define LED_COUNT 16
#define BUTTON_PIN 2
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int buttonState = 0;
int lastButtonState = 0;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
buttonState = digitalRead(BUTTON_PIN);
// Check if button is pressed
if (buttonState == HIGH && lastButtonState == LOW) {
// Run LED sequence
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
}
lastButtonState = buttonState;
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}