#include <Servo.h>
const int ldrPin = 34; // LDR connected to analog pin 34
const int servoPin = 0; // Servo motor connected to digital pin 14
const int threshold = 500; // Threshold value for LDR
Servo myServo; // Create a servo object
void setup() {
Serial.begin(115200);
pinMode(ldrPin, INPUT);
myServo.attach(servoPin); // Attach the servo motor to the servo object
}
void loop() {
int ldrValue = analogRead(ldrPin);
if (ldrValue > threshold) {
// Move the servo motor to a specific angle (e.g. 90 degrees)
myServo.write(90);
} else {
// Move the servo motor to a different angle (e.g. 0 degrees)
myServo.write(0);
}
delay(1000);
}