const int ldrPin = 34; // LDR connected to analog pin A0
const int ledPin = 12; // LED connected to digital pin D4
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int ldrValue = analogRead(ldrPin); // Read LDR value
Serial.println(ldrValue); // Print LDR value to Serial Monitor (optional)
if (ldrValue < 500) { // Adjust this threshold based on ambient light conditions
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
delay(1000); // Adjust delay as needed
}