LED Glow With Colors
LED Glow With Colors
#include <Adafruit_NeoPixel.h>
#define PIN 2 // Input pin Neopixel is attached to
#define NUMPIXELS 12 // Number of neopixels in Ring
int delayval=100;
// Define the color you want to glow
int redColor = 0; // Set red value (0-255)
int greenColor = 0; // Set green value (0-255)
int blueColor = 0; // Set blue value (0-255)
void setup() {
pixels.begin(); // Initializes the NeoPixel library.
pixels.clear(); // Clear all pixels at startup
pixels.show(); // Ensure the pixels are off initially
}
void loop() {
setColor();
for (int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(redColor, greenColor, blueColor)); // Set
the color for each pixel
}
pixels.show(); // Send the updated pixel color to the hardware
delay(delayval);
}
void setColor(){
redColor = random(0, 255);
greenColor = random(0,255);
blueColor = random(0, 255);
Serial.print("red: ");
Serial.println(redColor);
Serial.print("green: ");
Serial.println(greenColor);
Serial.print("blue: ");
Serial.println(blueColor);