I trying to have two sharp IR sensors track movement of a rod rotating at its center. I have attached a picture as a reference. The diagram is from a top-down view. Both IR sensors are pointing upwards. The rotating rod would pass above the IR sensors. I need each sensor to count every other pass of the rod, i.e., Having each sensor count only the odd pass numbers and ignore the even pass numbers. When the IR sensor is pointing to the ceiling, the arduino has a reading of around 10 or less units. When the rod passes over a sensor, the reading on the arduino is over 100. I tried to have the code count when the sensor reading is above 100 (again, doing this every other turn).
The problem is the IR sensor does many readings per second, per pass. This would make the arduino count several times for only a single pass of the rod. I was wondering if there was a way to tell the arduino that when it receives a reading of more than a hundred, no matter how many times, it will only count as one. It would wait untill it receives a small number (like 10) to continue the count once it receives a large number (like 100) again. This is all including the arduino ignoring every other turn.
I would greatly appreciate any help with this. Thanks.