#include <Servo.h>

Servo okservo;

int servopin = 9;
int ledyellow = 10;
int ledgreen = 11;
int buzzer = 12;
int ldr = A0;

void setup() {
  // put your setup code here, to run once:
okservo.attach(servopin);
pinMode (ledyellow,OUTPUT);
pinMode (ledgreen,OUTPUT);
pinMode (buzzer,OUTPUT);
pinMode (ldr,INPUT);
Serial.begin (9600);
}

void loop() {
  // put your main code here, to run repeatedly:
int ldrstatus = analogRead(ldr);

if (ldrstatus>250) {
okservo.write(90);
digitalWrite (ledyellow, LOW);
digitalWrite (ledgreen, HIGH);
tone (buzzer, 1000);
Serial.print ("bright");
Serial.println (ldrstatus);
}
else 
{
okservo.write(0);
digitalWrite (ledyellow, HIGH);
digitalWrite (ledgreen, LOW);
noTone (buzzer);
Serial.print ("ok");
Serial.println (ldrstatus);
}
}