/*
MSJ Researchers World
Date - 2nd DEC 2024
Mentor - Mr. Siranjeevi M
Contact - 7373771991
*/
#include <Adafruit_NeoPixel.h>
// Define NeoPixel settings
#define PIN 6 // Data pin connected to the NeoPixel
#define NUMPIXELS 16 // Number of LEDs in the strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// LDR settings
#define LDR_PIN A0 // Analog pin connected to the LDR
void setup() {
strip.begin(); // Initialize the NeoPixel strip
strip.show(); // Clear the strip
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read the LDR value
int ldrValue = analogRead(LDR_PIN);
Serial.println(ldrValue); // Print LDR value for debugging
// Map the LDR value to brightness (0 to 255)
int brightness = map(ldrValue, 0, 1023, 0, 255);
// Set NeoPixel color based on brightness
for (int i = 0; i < NUMPIXELS; i++) {
strip.setPixelColor(i, strip.Color(brightness, brightness, brightness)); // White light with adjustable brightness
}
strip.show();
delay(100); // Small delay for stability
}