const int ldrPin = 36;
const int relayPin = 23;
int ldrValue = 0;
int threshold = 500;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(ldrPin, INPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);
}
void loop() {
ldrValue = analogRead(ldrPin);
Serial.print("LDR Value: ");
Serial.println(ldrValue);
if (ldrValue < threshold) {
digitalWrite(relayPin, HIGH);
} else {
digitalWrite(relayPin, LOW);
}
delay(500);
}