#include <Servo.h>
Servo myservo; // create servo object to control a servo
int MotionSens = 10;
int LDRPin =7;
int buzzer=12;
int ledPin=8;
int pushsw=11;
int motiondet;
int servopin=3;
void setup() {
// put your setup code here, to run once:
myservo.attach(servopin); // attaches the servo on pin 9 to the servo object
pinMode(MotionSens,INPUT);
pinMode(ledPin,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(LDRPin,INPUT);
pinMode(pushsw,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
motiondet=digitalRead(MotionSens);
if(motiondet==HIGH)
{
digitalWrite(ledPin,digitalRead(LDRPin));
tone(buzzer, 262, 5000);
digitalWrite(buzzer,HIGH);
myservo.write(90);
delay(1000);
myservo.write(0);
delay(4000);
}
else
digitalWrite(ledPin,LOW);
digitalWrite(buzzer,LOW);
myservo.write(0);
}