//Connect ALL the expected conenctions properly, including the SERVO MOTORS
//Construct it such that if the PIR detects motion, the LED lights up and the SERVOs move.
//Add the ecessary codes, especially on to SERVOs.
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
int ldr = A0;
int servopin1 = 9;
int servopin2 = 10;
int servopin3 = 11;
int ledred = 13;
int PIRsensor = 8;
boolean start = false;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode (ledred, OUTPUT);
pinMode (PIRsensor, INPUT);
pinMode (ldr, INPUT);
servo1.attach(servopin1);
servo2.attach(servopin2);
servo3.attach(servopin3);
}
void loop() {
// put your main code here, to run repeatedly:
int ldrstatus = analogRead(ldr);
if (ldrstatus<250); {
if (digitalRead(PIRsensor) == HIGH) {
digitalWrite (ledred, HIGH);
servo1.write(180);
servo2.write(180);
servo3.write(180);
Serial.println("Motion detected");
Serial.println(ldrstatus);
}
else {
digitalWrite (ledred, LOW);
servo1.write(0);
servo2.write(0);
servo3.write(0);
Serial.println("Motion stopped.");
Serial.println(ldrstatus);
}
}
}