Person counter loop
Hi,
I'm still working on that person counter I posted about yesterday. Now I'm trying to figure out how to make the loop detect a person (in9 = 0), record the event (people = people + 1) and wait until the person leaves (in9 = 1). Right now what I have is supposed to do this, but whenever it detects someone in front of the sensor, it starts adding continually to the people varible. I already tried using a time delay, and it works, but I want this to be more advanced than that.
Thanks again.
Caleb
I'm still working on that person counter I posted about yesterday. Now I'm trying to figure out how to make the loop detect a person (in9 = 0), record the event (people = people + 1) and wait until the person leaves (in9 = 1). Right now what I have is supposed to do this, but whenever it detects someone in front of the sensor, it starts adding continually to the people varible. I already tried using a time delay, and it works, but I want this to be more advanced than that.
Thanks again.
Caleb
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
detect:
if sensor = low then
person = person + 1
go to cont
endif
go to detect
cont:
if sensor low then cont
go to detect········· 'if sensor goes HIGH· this will happen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
This is an application where manually debouncing your sensor input will help.· If you think about it, humans don't move particulary fast (relative to micros), so you can use a bit of code to make sure that your person sensor is active or not.· I would do something like this:
Check_Sensor:
· sensor = 1
· FOR idx = 1 TO 10
··· sensor = sensor & ~irInput
··· PAUSE 25
· NEXT
· RETURN
What this routine does is make sure that the person is present for at least 250 ms before·he/she is flagged as being present.· This will prevent sensor bouncing as a person enters/leaves the sensor zone from disturbing your count.· With sensor·and done being·bit variables, you can simplify you count code like this:
· peopleCount = peopleCount + (sensor * done)
With this, the only way peopleCount can be incremented is for both sensor and done to be "1."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax