const int ldrPin = PL0; // LDR connected to analog pin A0
const int ledPin = 13 D10; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int ldrValue = analogRead(ldrPin); // Read the LDR value (0-1023)
Serial.println(ldrValue); // Print LDR value to serial monitor for debugging
// Adjust the threshold value based on ambient light conditions
int threshold = 500;
if (ldrValue < threshold) {
digitalWrite(ledPin, HIGH); // Turn on the LED when it's dark
} else {
digitalWrite(ledPin, LOW); // Turn off the LED when it's bright
}