To know which direction a person is going, you will need two sensors, set a few inches apart. The direction is determined by which sensor trips first.
Think of sensor A as the count, and sensor B is the direction.
- If sensor B is high when sensor A trips, increment the count.
- If sensor B is low when sensor A trips, decrement the count.
This assumes that only one person passes through the sensor range at a time.