#include <Servo.h>

Servo myservo1;
int ledPin = 13;
int photoPin = 7;
int light=0;
bool droppedOnce = false;
int sensitivity = 1010;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
myservo1.attach(9);
myservo1.write(90);
digitalWrite(ledPin, HIGH);
delay (2000);
digitalWrite(ledPin, LOW);
}
int pos =0;
void loop() {
  light = analogRead(photoPin);
  if (light>sensitivity && droppedOnce) 
  {
    //digitalWrite(ledPin, HIGH);
    myservo1.write(150);
    droppedOnce = false;
    Serial.println("Open 2"); 
  }    
  else if (light>sensitivity)
  {
    //digitalWrite(ledPin, HIGH);
    myservo1.write(30);
    droppedOnce = true; 
    Serial.println("Open 1");
  }
  else
  {
    //digitalWrite(ledPin, LOW);
    myservo1.write(90);  
  }
  Serial.println(light); 
  while(light>sensitivity)
  {
    light = analogRead(photoPin);
    Serial.println(light); 
    delay (200);
  }
  delay (500);
}
