Microcontroller › 8051 › Automatic Bidirectional Visitor Counter › Hi, If man will stop at gate,
March 12, 2014 at 3:32 am
#11289
Participant
Hi,
If man will stop at gate, you will face this issue that it will continuously increase because this pin is using level instead of it you can program it to sense a edge.
I am assuming that sensor is giving logic 1 when it detects human and connected at pin P0.1
Try thhis
sbit sw=P0^1;
while (sw==0); // Wait till human is not detected
while (sw==1); // Wait till human is standnig in front of sensor
cnt++; // Increase counter value
Or something like
if (sw==1) // if human is detected
{
while (sw==1) ; // if human is standing infront of gate, wait till he moves on
cnt ++;
}