#include #define PIN 6 #define NUMPIXELS 8 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); const int buttonPin = 2; int currentColor = 0; void setup() { strip.begin(); strip.show(); pinMode(buttonPin, INPUT); setColor(255, 0, 0); } void loop() { int buttonState = digitalRead(buttonPin); if (buttonState == LOW) { delay(50); changeColor(); } } void setColor(uint8_t red, uint8_t green, uint8_t blue) { for(int i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(red, green, blue)); } strip.show(); } void changeColor() { currentColor = (currentColor + 1) % 3; if (currentColor == 0) { setColor(255, 0, 0); } else if (currentColor == 1) { setColor(0, 255, 0); } else { setColor(0, 0, 255); } delay(500); }