david_2018:
I think this may be related to the OP's other post Coding problem when using IF statement with Image attached - Project Guidance - Arduino Forum , I'm having a lot of difficulty trying to understand the explanations of what the code is suppose to do.
Exactly, that's why I'm asking in another way of it, to get as many result as possible.
There are 3 sensors. If people passing(being scanned, and leave) by S1, then S1 will +1. But if the person stand still, the sensor will become TRUE, will still +1 no matter where the people leave in either direction.
-----------> Enter
<----------- Exit
GOING IN I
S1 S2 S3
1 0 0 //1 People coming in
True False False
S1 S2 S3
1 1 0 //He is continuing moving
False True False
S1 S2 S3
1 1 1 //He is entering the building
False False True
GOING IN & GETTING BLOCK I
S1 S2 S3
1 0 0 //1 People coming in
True False False
S1 S2 S3
1 1 1 //He is continuing moving, but another person wanna go out
False True True
S1 S2 S3
1 1 2 //He is entering the building after another person give the way
False False True
GOING IN & TURN BACK I
S1 S2 S3
1 0 0 //1 People coming in
True False False
S1 S2 S3
1 1 0 //He's seems like forget something
False True False
S1 S2 S3
2 1 0 //He's turn back and go somewhere else
True False False
S1 or S3 may get higher value if many people refuse to go in at S1, or refuse to go out at S3.
The value in S1 or S3 will be disappear after 5 second if not being used for peopleCounted.
But if people coming in a row, it will also produce the value more than 2 or 3.
GOING IN III
S1 S2 S3
1 0 0 //1 People coming in
True False False
S1 S2 S3
2 1 0 //He is continuing moving, another people following up
True True False
S1 S2 S3
3 2 1 //He is entering the building, the second people still following, the third people following too
True True True
At the point when a person is successfully enter a building, peopleCounted++, S1--, S2--.
It also applied in the reverse way when someone leaving, peopleCounted--, S3--, S2--.
The whole process may not happened instantly or 100% in this pattern, may slow a bit or faster a bit.
I had used IF statement to include another IF statement, and on, and on, and on.
It seems like the IF statement is doing the thing I want which is IF this, THEN this, THEN that.
But to get the final result, which is peopleCounted++ or --, it might not works unless the situation is 100% correct and instantly.
Will the trigged frequency of Ultrasonic Sensor affect the final result? Or actually I'm using a wrong way to make things done?