-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson_Counter_v4.ino
101 lines (92 loc) · 2.15 KB
/
Person_Counter_v4.ino
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
int ldr1 = A0;
int ldr2 = A1;
int total = 0;
float threshhold1 = 200;
float threshhold2 = 200;
int entering = 0;
int exiting = 0;
int flag = 0;
void setup()
{
pinMode(ldr1, INPUT);
pinMode(ldr2, INPUT);
Serial.begin(9600);
String data = "PERSON COUNTER\nTotal = ";
data.concat(total);
Serial.println(data);
/*Serial.println("PERSON COUNTER");
Serial.print("total=");
Serial.println(total);
Serial.print("Entered=");
Serial.println(entering);
Serial.print("Exitted=");
Serial.println(exiting);*/
}
void loop()
{
String data="";
if (analogRead(ldr1) <= threshhold1 && analogRead(ldr2) >= threshhold2)
{
while (flag == 0)
{
if (analogRead(ldr1) >= threshhold1 && analogRead(ldr2) <= threshhold2)
{
entering++;
total = total + 1;
data = "PERSON COUNTER\nTotal = ";
data.concat(total);
Serial.println(data);
flag = 1;
}
else if (analogRead(ldr1) <= threshhold1 && analogRead(ldr2) <= threshhold2)
{
if (analogRead(ldr1) >= threshhold1 && analogRead(ldr2) <= threshhold2)
{
entering++;
total = total + 1;
data = "PERSON COUNTER\nTotal = ";
data.concat(total);
Serial.println(data);
flag = 1;
}
else
{
flag = 1;
}
}
}
flag = 0;
}
if (analogRead(ldr1) >= threshhold1 && analogRead(ldr2) <= threshhold2)
{
while (flag == 0)
{
if (analogRead(ldr1) <= threshhold1 && analogRead(ldr2) >= threshhold2)
{
exiting++;
total = total - 1;
data = "PERSON COUNTER\nTotal = ";
data.concat(total);
Serial.println(data);
flag = 1;
}
else if (analogRead(ldr1) <= threshhold1 && analogRead(ldr2) <= threshhold2)
{
if (analogRead(ldr1) <= threshhold1 && analogRead(ldr2) >= threshhold2)
{
exiting++;
total = total - 1;
data = "PERSON COUNTER\nTotal = ";
data.concat(total);
Serial.println(data);
flag = 1;
}
else
{
flag = 1;
}
}
}
flag = 0;
}
}