const int photoresistorPin = A0;
const int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(photoresistorPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
int lightValue = analogRead(photoresistorPin);
Serial.println(lightValue);
// Adjust the threshold value according to the ambient light conditions
int threshold = 500;
if (lightValue < threshold) {
digitalWrite(ledPin, HIGH); // Turn on the LED when it's dark
} else {
digitalWrite(ledPin, LOW); // Turn off the LED when it's light
}
delay(1000); // Adjust the delay according to your preference
}