#include <FastLED.h>
#define NUM_LEDS 49 // Neopixel ring with 12 LEDs
#define DATA_PIN 0 // Pin connected to the data input of the ring
#define LED_TYPE WS2812B // LED type for Neopixel rings
#define COLOR_ORDER GRB // Most Neopixel rings use GRB order
int x = 10;
CRGB leds[NUM_LEDS];
unsigned long previousMillis = 0; // Timer variable
const int switchInterval = x*1000; // Time to switch colors in milliseconds (7 seconds)
bool colorToggle = false; // To track color state
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
}
void loop() {
unsigned long currentMillis = millis(); // Get the current time
// Check if the switch interval has passed
if (currentMillis - previousMillis >= switchInterval) {
previousMillis = currentMillis; // Reset the timer
colorToggle = !colorToggle; // Toggle color
}
// Set the color based on the toggle state
if (colorToggle) {
fill_solid(leds, NUM_LEDS, CRGB(175, 21, 83)); // Color 1
} else {
fill_solid(leds, NUM_LEDS, CRGB(40, 185, 115)); // Color 2
}
FastLED.show(); // Display the colors
}