const int ldrPin = A0;
const int ledPin = 7;
int lightValue = 0;
int threshold = 500; // Adjust if needed
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
lightValue = analogRead(ldrPin);
Serial.print("Light Value: ");
Serial.println(lightValue);
// Dark -> LED ON
if (lightValue < threshold) {
digitalWrite(ledPin, HIGH);
}
// Bright -> LED OFF
else {
digitalWrite(ledPin, LOW);
}
delay(200);
}