// Include the necessary libraries
#include <Arduino.h>
// Define the pin for the LDR sensor
const int ldrPin = 23;
// Define a threshold value for the LDR (you can adjust this as needed)
const int threshold = 500;
void setup() {
// Initialize serial communication for debugging
Serial.begin(115200);
}
void loop() {
// Read the analog value from the LDR
int ldrValue = analogRead(ldrPin);
// Check if the LDR value is below the threshold
if (ldrValue < threshold) {
Serial.println("LDR is ON");
} else {
Serial.println("LDR is OFF");
}
// Add a delay to avoid rapid serial output
delay(1000);
}