#include <Servo.h>
Servo myservo; // Create a Servo object
const int photoresistorPin = A0; // Pin for the photoresistor
const int servoPin = 9; // Pin for the servo
void setup() {
myservo.attach(servoPin); // Attaches the servo to the servo pin
pinMode(photoresistorPin, INPUT); // Set the photoresistor pin as an input
}
void loop() {
int sensorValue = analogRead(photoresistorPin); // Read the value from the photoresistor
int servoAngle = map(sensorValue, 0, 1023, 0, 180); // Map the value to a servo angle
myservo.write(servoAngle); // Set the servo to the calculated angle
delay(5); // Delay to allow the servo to move
}