#include <Adafruit_NeoPixel.h>
#define NEOPIXEL_DIN 15 // Note: D15 on NodeMCU is mapped to GPIO15
#define NUMPIXELS 300
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, NEOPIXEL_DIN, NEO_GRB + NEO_KHZ800);
void setup() {
// Initialize serial communication
Serial.begin(115200);
Serial.println("Happy Halloween!");
// Initialize NeoPixel strip
strip.begin();
strip.show(); // Initialize all pixels to 'off'
// Seed random number generator
randomSeed(analogRead(0));
}
void loop() {
int flicker;
uint8_t myRed, myGrn;
float dimmer = 1.0; // Change this value to set the overall brightness (0.0 to 1.0)
for (int i = 0; i < NUMPIXELS; i++) {
flicker = random(0, 40); // Flicker intensity, you can change the range
myRed = max((int)((255 - flicker) * dimmer), 0);
myGrn = max((int)((40 - flicker) * dimmer), 0);
// Set pixel color here.
strip.setPixelColor(i, strip.Color(myRed, myGrn, 0));
}
// Refresh the strip
strip.show();
delay(100); // Delay for effect (50 ms)
}