#include <Servo.h>
Servo myservo;
#define ldr1pin A1
#define ldr2pin A0
int angle = 90;
int threshold = 20;
void setup() {
myservo.attach(13);
myservo.write(angle);
Serial.begin(9600);
// put your setup code here, to run once:
}
void loop() {
int ldr1value = analogRead(ldr1pin);
int ldr2value = analogRead(ldr2pin);
if (((ldr1value-ldr2value)<threshold)||((ldr2value-ldr1value)<threshold)){
}
else{
if(ldr1value>ldr2value){
angle--;
}
else{
angle++;
}
angle.constrain(angle,75,120);
myservo.write(angle);
}
// put your main code here, to run repeatedly:
}