//LED Ring
#include <Adafruit_NeoPixel.h>
#define BUTTON_PIN 11
bool LED_ON = false;
#define PIN 12 // Define the pin where the data line is connected
#define NUMPIXELS 16 // Define the number of pixels in your LED ring
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void LED_UPDATE() {
pixels.show(); // Update the Neopixel with the new color
}
void LED_CHANGECOLOR(int CC_R,int CC_G,int CC_B,int pixelcount, bool updatecolor = true) {
pixels.setPixelColor(pixelcount, pixels.Color(CC_R, CC_G, CC_B)); // Set the custom color
if (updatecolor) {LED_UPDATE();}
}
void LED_UPDATEALL(int CC_R,int CC_G,int CC_B, bool updatecolor = true) {
for (int updateprogress = 0; updateprogress<NUMPIXELS; updateprogress++) {
LED_CHANGECOLOR(CC_R,CC_G,CC_B,updateprogress,false);
}
if (updatecolor) {LED_UPDATE();}
}
void LED_Test() {
for (int i = 0; i<16; i++) {
LED_CHANGECOLOR(255,0,0,i);
delay(50);
}
for (int i = 0; i<16; i++) {
LED_CHANGECOLOR(0,255,0,i);
delay(50);
}
for (int i = 0; i<16; i++) {
LED_CHANGECOLOR(0,0,255,i);
delay(50);
}
LED_UPDATEALL(0,0,0);
delay(200);
LED_UPDATEALL(255,255,255);
delay(200);
LED_UPDATEALL(0,0,0);
delay(200);
LED_UPDATEALL(255,255,255);
delay(100);
}
void setup() {
Serial.begin(115200);
pixels.begin(); // Initialize the Neopixel library
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
if (!LED_ON) {
while (digitalRead(BUTTON_PIN)) {
delay(50);
}
LED_Test();
LED_UPDATEALL(0,150,255);
}
delay(50);
}