- This topic has 1 reply, 2 voices, and was last updated 13 years, 9 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › Please give me c coding for bidirectional visitor counter using AT89C52
here i am writing the algo code it by yourself
i assumed
the RX1 is inside the room and rx2 is out side the room….
the variable for the number of came person inside a room is total_in
similarly the number of person outside the room is total_out
and the number of person present in side is present_in = total_in – total_out;
let the sensors are connected to port1
Rx1 to P1.0
Rx2 to P1.1
rest of the pins are high
when any one comes inside the room first out sensor will sens the person and the inside one
similarly when any one goes out side from room the inside sensor will sense the person first then the out side one
the sensors are active low o/p
algo:
while(1)
{
while(P1= 0 0xff)
if(P1_0= =0) // inside sensor ; person is going out
{
while(P1_1 = = 1);
total_out++;
delay_1s( );
}
else if(P1_1= =0) // outside sensor ; person is comming inside
{
while(P1_0 = = 1);
total_in++;
delay_1s( );
}
present_in = total_in – total_out;
display(present_in);
}