#include <Servo.h> Servo myservo; int val; void setup() { Serial.begin(9600); myservo.attach(9); //Pin where Servo motor signal is conected. } void loop() { val = analogRead(7); //Pin where LDR is conected. Serial.println(val); //val = map(val, 850, 1023, 0, 180); //1st values is resistor values input, and second is the servo angle, eg, 850 reading is 0 Deg. if (val > 1010) //if above it will move to 45 { myservo.write(70); //angle when light } else if (val < 1015) // if less then move back to 0 { myservo.write(18); //angle when dark } delay(25); }