// PIR Motion Senor attached to LED (Replacement for DC motor) by Ashwin Jayan
#include <Servo.h> //Inlcudes the servo library
Servo servo;
boolean lastMotion = 0;
void setup() {
Serial.begin(9600);
pinMode(8, INPUT); //Checks the status of the motion sensor
servo.attach(10); //Takes the servo input pin as 10
servo.write(0);
}
void loop() {
int currentMotion = digitalRead(8); //Reads the value of the 8 pin
if(currentMotion ==1){
if(lastMotion == 0){
lastMotion = 1;
Serial.println("Motion Detected"); //Prodcues if it is high or low on the terminal
servo.write(180); //Makes the servo motor move by 100 degrees
delay(2000);
servo.write(0);
}
}
else{
lastMotion = 0;
}
}