#include <Servo.h>
#define LDR_PIN 2
Servo myservo;
int pos = 75;
int LDR1 = A0;
int LDR2 = A1;
int d = 50;
void setup() {
myservo.attach(5);
pinMode(LDR1, INPUT);
pinMode(LDR2, INPUT);
}
void loop() {
int analogValue1 = analogRead(LDR1);
int analogValue2 = analogRead(LDR2);
if (analogValue1 > analogValue2) {
pos = pos+1;
delay(d);
}
if (analogValue1 < analogValue2) {
pos = pos-1;
delay(d);
}
if (pos < 0) {
pos = 0;
delay(d);
}
if (pos > 180) {
pos = 180;
delay(d);
}
myservo.write(pos);
delay(d);
}