// put #include <Adafruit_NeoPixel.h>
const int buttonPin = D1;
const int led1Pin = D7;
const int led2Pin = D6;
const int maxClicks = 5;
int clickCount = 0;
int Power = 11;
int PIN = 12;
#define NUMPIXELS 2
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin();
pinMode(Power, OUTPUT);
digitalWrite(Power, HIGH);
pinMode(buttonPin, INPUT);
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
delay(50); // Debounce delay
if (digitalRead(buttonPin) == HIGH) {
clickCount++;
clickCount = min(clickCount, maxClicks);
activateLEDs();
delay(500);
clickCount = 0;
}
}
}
void activateLEDs() {
for (int i = 0; i < clickCount; i++) {
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, HIGH);
// changes color of the NeoPixel
pixels.clear();
pixels.setPixelColor(0, pixels.Color(15, 25, 205));
pixels.show();
delay(400);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(103, 25, 205));
pixels.show();
delay(400);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(233, 242, 205));
pixels.show();
delay(400);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(233, 23, 23));
pixels.show();
delay(400);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(12, 66, 101));
pixels.show();
delay(400);
delay(500);
// turns off LEDs y NeoPixel
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, LOW);
pixels.clear();
pixels.show();
}
}
your code here