//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 No4;
Servo No2;
Servo No3;
int ldr = A0;
int ledred = 13;
int PIRsensor = 8;
int servopin0 =5;
int servopin2 =6;
int servopin3 =3;
boolean start = false;
void setup() {
// put your setup code here, to run once:
No4.attach(servopin0);
No2.attach(servopin2);
No3.attach(servopin3);
Serial.begin(9600);
pinMode (ledred, OUTPUT);
pinMode (PIRsensor, INPUT);
pinMode (PIRsensor, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int ldrstatus = analogRead(ldr);
if (ldrstatus<250){
if (digitalRead(PIRsensor) == HIGH) {
No4.write(180);
No2.write(0);
No3.write(0);
digitalWrite (ledred, HIGH);
Serial.println("Motion detected");
}
else {
No4.write(90);
No2.write(90);
No3.write(90);
digitalWrite (ledred, LOW);
Serial.println("Motion stopped.");
}
}
}