// Project: Luminous Logic: Light-Triggered Lighting
const int ldrPin = A0; // LDR connected to analog pin A0
const int ledPin = 9; // LED connected to digital pin 9
int lightLevel;
int threshold = 500; // Adjust this value based on your room lighting
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // For monitoring light level
}
void loop() {
lightLevel = analogRead(ldrPin);
Serial.println(lightLevel); // Optional: check values in Serial Monitor
if (lightLevel < threshold) {
digitalWrite(ledPin, HIGH); // It's dark, turn LED ON
} else {
digitalWrite(ledPin, LOW); // It's bright, turn LED OFF
}
delay(100); // Short delay
}