const int photoresistorPin = A0; // Analog pin to read the photoresistor
const int ledPin2 = 3; // Digital pin for LED 2
void setup() {
pinMode(ledPin2, OUTPUT);
pinMode(photoresistorPin, INPUT);
Serial.begin(9600);
}
void loop() {
int lightLevel = analogRead(photoresistorPin);
if (lightLevel > 500) { // Adjust this threshold based on your ambient light conditions
digitalWrite(ledPin2, HIGH); // Turn on LED 3 when it's dark
} else {
digitalWrite(ledPin2, LOW); // Turn off LED 3 when it's day
}
Serial.println(lightLevel); // Print the light level for debugging
delay(1000); // Delay for stability and to avoid rapid switching
}