#include <Servo.h>
Servo myservo;
int servo_motor = 10;
int led = 11; // LED anode pin number 11
int pir = 12;// PIR Signal to pin number 12
void setup() {
// put your setup code here, to run once:
pinMode(pir, INPUT);
pinMode(led, OUTPUT);
myservo.attach(9);
Serial.begin(9600);// transfer the data from pir to arduino.Speed here is the transfer rate
}
void loop() {
// put your main code here, to run repeatedly:
int value_of_pir = digitalRead(pir);//Get the input form Pir to the arduino(processor) geting the motion
if(value_of_pir==HIGH)
{
digitalWrite(led, HIGH);
myservo.write(180); // angle of ratation os Servo ARM
Serial.println("Motion Detected");
}
else{
digitalWrite(led, LOW);
myservo.write(0); //Initial Angle of SERVO ARM
Serial.println("Motion not detected");
}
}