#include <Adafruit_NeoPixel.h>
// Declare a NeoPixel strip object with the specified number of pixels and pin number
#define NUM_PIXELS 16
#define buttonPin 12
Adafruit_NeoPixel strip(NUM_PIXELS, 6, NEO_GRB + NEO_KHZ800);
int buttonState = 0;
int lastButtonState = 0;
int state = 0;
void setup() {
// Initialize serial communication
Serial.begin(9600);
pinMode(buttonPin, INPUT);
strip.begin();
strip.clear();
// Show the changes on the strip
strip.show();
}
void rainbow() {
for (int i = 0; i < NUM_PIXELS; i++) {
// Calculate the color values for the pixel
int r = (i * 255) / (NUM_PIXELS - 1);
int b = 255 - r;
// Set the pixel to the calculated color
strip.setPixelColor(i, strip.Color(r, 0, b));
}
// Show the changes on the strip
strip.show();
}
void dynamicRainbow() {
}
void dynamicRing() {
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState && buttonState == HIGH) {
state++;
state = state % 3;
Serial.println(state);
}
lastButtonState = buttonState;
switch(state) {
case 0:
rainbow();
case 1:
rainbow();
case 2:
rainbow();
}
delay(5);
}