const int ldrPin = A0;
const int ledPin = 9;
int ldrValue = 0;
const int threshold = 500;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
ldrValue = analogRead(ldrPin);
Serial.println(ldrValue);
if (ldrValue < threshold) {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);
}
delay(100);
}