#include <Servo.h>
Servo myservo;
int pir=7;
void setup()
{
  pinMode(pir,INPUT);
  pinMode(2,OUTPUT);
  myservo.attach(8);
}
void loop()
{
  
  int val = digitalRead(pir);
  if(val==HIGH){
    myservo.write(180);
    digitalWrite(2, HIGH);
    delay(3000);
  }
  else{
    myservo.write(0);
    digitalWrite(2, LOW);
  }
}