You are on page 1of 5

/******************************************************

www.firmcodes.com

DEVELOPED BY:- FIRMWARE DEVELOPER

WHAT PROGRAM DO:- Program of Visitor Counter with 8051 using LCD

******************************************************/

#include<reg51.h>

#include"lcd.h"

sbit ir1=P0^0; // sensor 1

sbit ir2=P0^1; // sensor 2

unsigned int m='0',n='0',p,q;

void loop1();

void loop2();

void delay_fv(unsigned int x,unsigned int y);

/******************************

main Program

******************************/

void main()
{

p=q=0;

lcd_ini(); // lcd intialize

lcd_str("WELCOME");

while(1)

p=q=0;

if(ir1==0)

while(p==0)

loop1();

delay_fv(100,100);

else if(ir2==0)

while(q==0)

loop2();

delay_fv(100,100);

}
void loop1() // when person exit the room

if(ir2==0)

m++;

if(m==':')

m='0';

n++;

cmd(0x01);

delay_fv(100,150);

lcd_str("NO. OF VISIT:");

lcd_display(n);

lcd_display(m);

cmd(0xc0);

lcd_str("WELCOME");

delay_fv(100,150);

p=1;

delay_fv(100,100);

delay_fv(100,100);

while(ir2==0);

}
void loop2() // person enter the room

if(ir1==0)

m--;

if(m==':')

m='9';

n--;

cmd(0x01);

delay_fv(100,150);

lcd_str("NO. OF VISIT:");

lcd_display(n);

lcd_display(m);

cmd(0xc0);

lcd_str("THANK YOU");

delay_fv(100,150);

q=1;

delay_fv(100,100);

delay_fv(100,100);

if(m=='0' && n=='0')

cmd(0x01);
lcd_str(" ROOM IS EMPTY");

return;

while(ir1==0);

void delay_fv(unsigned int x,unsigned int y) // delay

unsigned int i,j;

for(i=0;i<x;i++)

for(j=0;j<y;j++);

You might also like