//external library which will be used to set functionalities of Servo motor
#include <Servo.h>
Servo myservo; // call the myservro functions
int servo_motor = 10; // SERVO motor to PIN no 10
int led=11;// LED anode PIN no 11
int pir=12;//PIR Signal to PIN no 12
void setup()
{
pinMode(pir,INPUT);
pinMode(led,OUTPUT);
myservo.attach(9); //pin number 9
Serial.begin(9600); //will help to communicate with other connected devices and arduino.
}
void loop()
{
int value_of_pir = digitalRead(pir);// Get the Input from PIR to Processor
if(value_of_pir==HIGH)
{
digitalWrite(led,HIGH);
myservo.write(180);// angle of rotation of SERVO ARM
Serial.println("Motion Detected");
}
else
{
digitalWrite(led,LOW);
myservo.write(0); // Initial Angle of SERVO ARM
Serial.println("Motion Completed");
}
}
//OUTPUT- Click on PIR sensor and then click on simulate Motion buton (on top) to get LED glow