#include <Servo.h>
const int MOTION_SENSR_PIN_1 = 7;
const int MOTION_SENSR_PIN_2 = 6;
const int MOTION_SENSR_PIN_3 = 5;
const int MOTION_SENSR_PIN_4 = 4;
const int SRVO_PIN = 9;
int angle = 0;
int lastMotionState;
int currentMotionState;
void setup() {
Serial.begin(9600);
pinMode(MOTION_SENSOR_PIN1, 'INPUT 7');
pinMode(MOTION_SENSOR_PIN2, 'INPUT 6');
pinMode(MOTION_SENSOR_PIN3, 'INPUT 5');
pinMode(MOTION_SENSOR_PIN4, 'INPUT 4');
servo.attach(SeRVO_PIN);
}
void loop() {
lastMotionState = currentMotionState;
currentMotionState = digitalRead(MOTION_SENSOR_PIN);
currentMotionState = digitalRead(MOTION_SENSOR_PIN);
currentMotionState = digitalRead(MOTION_SENSOR_PIN);
currentMotionState = digitalRead(MOTION_SENSOR_PIN);
if (currentMotionState == LOW & lastMotionState == HIGH) {
servo.write(90);
}
else
if (currentMotionState == HIGH & lastMotionState == LOW) {
servo.write(0);
}
for (angle = 0; angle = 180; angle += 1) {
servo.write(angle);
delay(10);
}
for (angle = 180; angle = 0; angle -= 1) {
servo.write(angle);
delay(10);
}
}