IR Counting
Austin S.
Posts: 5
Hello,
I have a BS2 and I am using IR sensors. My project requires me to count how many times an IR sensor detects an object. Is there a special command I can use for this?
Any advice or comments would be appreciated!
Thanks!
Post Edited (Austin S.) : 1/25/2010 1:18:45 AM GMT
I have a BS2 and I am using IR sensors. My project requires me to count how many times an IR sensor detects an object. Is there a special command I can use for this?
Any advice or comments would be appreciated!
Thanks!
Post Edited (Austin S.) : 1/25/2010 1:18:45 AM GMT
Comments
What code do you have and can you explain the whole object of your project?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
IF (IRLED = 0) THEN
DO WHILE (IRLED = 0)
limitcounter = limitcounter + 1
LOOP
ELSEIF (limitcounter >= limit) THEN
Count = Count + 1
limitcounter = 0
ELSE
limitcounter = 0
ENDIF
DEBUG HOME, DEC3 ? Count
LOOP
this "should" work if your counting is relatively slow.
if object is detected it increments a limitcounter to filter out false readings.
And when the detector doesn't detect it checks the limitcounter against your set limit and if it was a positive reading COUNT increments by one. and the limitcounter is reset
If it wasnt enough to pass the limit test. limitcounter is reset to begin the next check.
limit needs to be set based on speed / experimentation.
Post Edited (Campeck) : 1/25/2010 6:22:03 PM GMT
a:if in0=0 then a' sensor on pin0, normally low, triggered=high
debug "count=",dec b0, cr' debug output
pause 1000' optional, wait 1 sec to prevent double triggers (adjustable)
next' end loop
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."