#include <Servo.h>
Servo myservo;
int pos = 1;

int LDR1 = A0;
int LDR2 = A1;
int value1;
int value2;
void setup() {
  Serial.begin(9600);
  pinMode(LDR1, INPUT);
  pinMode(LDR2, INPUT);
  myservo.attach(9);
  myservo.write(1);

}

void loop() {
  value1 = analogRead(LDR1);
  value2 = analogRead(LDR2);
  Serial.print(value1);
  Serial.print("|");
  Serial.println(value2);

  if (value1 < 780 && pos<=5 && value2 >900) {
    for (pos = 1; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
      // in steps of 1 degree
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
  }

  if (value2 < 820 && pos>=85 && value1 >870) {
    for (pos = 90; pos >= 1; pos -= 1) { // goes from 180 degrees to 0 degrees
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
  }
}