// PIR Motion Senor attached to LED (Replacement for DC motor) by Ashwin Jayan
#include <Servo.h> //Inlcudes the servo library
Servo servo;
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
}
void loop() {
int input = digitalRead(8); //Reads the value of the 8 pin
Serial.println(input); //Prodcues if it is high or low on the terminal
if(input == 1) { //Checks if the motion sensor has been tripped
int position = 0; //Makes current position of servo as 0
servo.write(100); //Makes the servo motor move by 100 degrees
delay(1000);
}
if(input == 0){ //If not trippped
servo.write(0);//Returns the servo back to original position
delay(1000);
}
delay(1800); //Delay between the motion sensor and servo
}