I'm trying to make a room visitor counter, to control my room lights. Theres 2 lasers on one side of the wall, and 2 photoresistors on the other side. The setup forms 2 trip wires, and depending on which got tripped first, I know if a person walked in or out of the room. I tried coding this before, but failed miserably. Can somebody give me any ideas or where to start? I'd need a counter that starts when one of the wires is tripped, and keeps checking if the other trips during that time.
I'd need a counter that starts when one of the wires is tripped, and keeps checking if the other trips during that time.
No, you need to know WHEN each laser got tripped. The only way that this device will work is if several conditions are met. First, only one person at a time can go through the trip zone at a time. If one person can enter while another is leaving, you will not be able to detect that.
Second, once a person starts to enter, they can not back up and not complete entry.
Third, a person must actually fully enter the room. Waving a hand past the lasers to simulate entering or leaving the room must physically not be possible.
If, somehow, you have managed to assure that all of those conditions is true, then a trip wire system is probably not the easiest means of counting entries and exits.
However, if you record when each laser is tripped, and the fact that it has been tripped, you can, determine, on each pass through loop, whether both have been tripped, which means that an entry or exit has occured. When both have been tripped, subtract the time one was tripped from the time that the other was tripped. It the result is positive, the lasers were tripped in one order (either an entry or an exit, depending on which value you subtract from which value). If the result is negative, the lasers were tripped in the other order.
PaulS: If, somehow, you have managed to assure that all of those conditions is true, then a trip wire system is probably not the easiest means of counting entries and exits.
What would be a better way of doing this then?