#include <Servo.h>
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int val = 0; // variable for reading the pin status
Servo actuator; // create servo object to control a servo
void setup() {
Serial.begin(9600);
actuator.attach(9); // attaches the servo on pin 9 to the servo object
actuator.write(0);
}
void loop() {
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
// we have just turned on
Serial.println("Motion detected!");
actuator.write(90);
delay(700);
actuator.write(0);
delay(5000);
}
delay(5000);
}