1int firstIRsensor=A0;
2int secondIRsensor=A1;
3
4int firstinput=12;
5int secondinput=11;
6int musicpin=10;
7float a;
8float b;
9
10void setup()
11{
12 Serial.begin(9600);
13 pinMode(firstIRsensor,INPUT);
14 pinMode(secondIRsensor,INPUT);
15 pinMode(firstinput,OUTPUT);
16 pinMode(secondinput,OUTPUT);
17 pinMode(musicpin,OUTPUT);
18}
19
20void loop()
21{
22 a=analogRead(firstIRsensor);
23
24 if(a>300)
25 {
26 digitalWrite(musicpin,HIGH);
27 digitalWrite(firstinput,LOW);
28 digitalWrite(secondinput,LOW);
29 delay(10000);
30
31
32 inside();
33 }
34 if(a<300)
35 {
36
37 digitalWrite(musicpin,LOW);
38 digitalWrite(firstinput,LOW);
39 digitalWrite(secondinput,LOW);
40 }
41}
42
43void inside()
44{
45 digitalWrite(musicpin,LOW);
46 digitalWrite(firstinput,LOW);
47 digitalWrite(secondinput,LOW);
48 delay(8000);
49 b=analogRead(secondIRsensor);
50Serial.println(b);
51 if(b>300)
52
53{
54 digitalWrite(musicpin,LOW);
55 digitalWrite(firstinput,LOW);
56 digitalWrite(secondinput,HIGH);
57 delay(2000);
58 digitalWrite(musicpin,LOW);
59 digitalWrite(firstinput,LOW);
60 digitalWrite(secondinput,LOW);
61 delay(5000);
62 digitalWrite(musicpin,LOW);
63 digitalWrite(firstinput,HIGH);
64 digitalWrite(secondinput,LOW);
65 delay(2000);
66 digitalWrite(musicpin,LOW);
67 digitalWrite(firstinput,LOW);
68 digitalWrite(secondinput,LOW);
69 delay(3000);
70}
71if(b<300)
72{
73 digitalWrite(musicpin,LOW);
74 digitalWrite(firstinput,LOW);
75 digitalWrite(secondinput,LOW);
76 delay(3000);
77}
78
79
80}
81
82