#include <Servo.h>
Servo myservo;
int servo_motor = 10;
int led = 11;
int pir = 12;
void setup()
{
// put your setup code here, to run once:
pinMode(pir, INPUT);
pinMode(led, OUTPUT);
myservo.attach(9);
Serial.begin(9600);
}
void loop()
{
// put your main code here, to run repeatedly:
int value_of_pir = digitalRead(pir);
if (value_of_pir == HIGH){
digitalWrite(led, HIGH);
myservo.write(180);
Serial.println("Motion Detected");
}
else
digitalWrite(led, LOW);
myservo.write(0);
Serial.println("Motion Completed");
}