My pseudocode was by no means intended to be complete; rather, it was intended to give a general sense of concept donkey was describing. A few posts up, donkey suggests a spacing of 30 cm between the two beams. This is about 1 foot. If someone walks into a room less that one foot and changes their mind, they will have only tripped
sensor 1. According to my pseudocode, they would have to trip
both sensor 1 and sensor 2,
and the time difference between the two trips cannot be greater than 5 seconds. This would mean if they walked into the room less than one foot, then turned around and walked out, it is true that
sensor 1 would be tripped twice. However, since
sensor 2 was not tripped at all, the time difference between the two trips would be greater than five seconds, and therefore the condition is false, which does not result in an increment or a decrement. If they did trip
sensor 2, then change their mind and exit,
sensor 1 would show the later time, and both triggers being within five seconds of each other, would properly decrement. (Ah, I see what you mean... this is wrong, considering it did not first properly register an increment. Gotcha.)
After you detect the break in sensor 1, put in a delay of 6 seconds before any logic is processed. This gives sensor two plenty of time to be tripped and detected within the logic window. That way, it is possible to detect both entering and leaving.
If you think you have a better solution, please feel free to modify my logic. You know what you want moreso than I. I'm just glad to get you started.
If you really want a super-accurate count, make sure people file past the detectors one-by-one, single-file. Even better, use a
P.S. - You're welcome, donkey. Happy to help anywhere I can. After programming for years in college, I might as well put it use somewhere, right?!
