-
Notifications
You must be signed in to change notification settings - Fork 0
/
code
47 lines (41 loc) · 768 Bytes
/
code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <Servo.h>
Servo servo_test;
int mr_1=4;
int mr_2=5;
int buzzer=2;
int tilt_1=7;
int tilt_2=8;
int pir_pin=6;
int pir_stat=0;
int val_1=0;
int val_2=0;
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(mr_1, OUTPUT);
pinMode(mr_2, OUTPUT);
pinMode(tilt_1, INPUT);
pinMode(tilt_2, INPUT);
pinMode(pir_pin, INPUT);
servo_test.attach(3);
}
void loop()
{ pir_stat=digitalRead(pir_pin);
val_1=digitalRead(tilt_1);
val_2=digitalRead(tilt_2);
if (val_1==LOW)
{digitalWrite(mr_1,HIGH);
digitalWrite(mr_2,LOW);}
else
{digitalWrite(mr_1,LOW);
digitalWrite(mr_2,LOW);
}
if(pir_stat==HIGH && val_2==LOW)
{servo_test.write(60);
digitalWrite(buzzer,HIGH);
delay(100);}
else
{servo_test.write(0);
digitalWrite(buzzer,LOW);
}
}