#include <Adafruit_NeoPixel.h>
#define LDR_PIN A0
#define NEO_PIN 6
#define NUM_PIXELS 16
Adafruit_NeoPixel ring(NUM_PIXELS, NEO_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
pinMode(LDR_PIN, INPUT);
ring.begin();
ring.setBrightness(150); // Scale down brightness slightly for clean simulation
ring.show(); // Initialize all pixels to 'off'
}
void loop() {
// Read ambient light levels (Wokwi LDR outputs 0-1023)
int lightValue = analogRead(LDR_PIN);
Serial.print("Ambient Light Raw: ");
Serial.println(lightValue);
// Map the lighting into an intensity scale
// Darker environment = higher neon illumination intensity
int intensity = map(lightValue, 0, 1023, 255, 0);
intensity = constrain(intensity, 0, 255);
// Generate a smooth neon gradient shift based on brightness level
// Brighter room = Cyan (0, 255, 255) | Pitch dark = Cyber Magenta (255, 0, 150)
uint8_t r = map(intensity, 0, 255, 0, 255);
uint8_t g = map(intensity, 0, 255, 255, 0);
uint8_t b = map(intensity, 0, 255, 255, 150);
// Apply colors across all pixels smoothly
for (int i = 0; i < NUM_PIXELS; i++) {
ring.setPixelColor(i, ring.Color(r, g, b));
}
ring.show();
delay(100); // 10Hz refresh rate for fluid color transitions
}