Spread the love

VISITOR COUNTER WITH 8051


Working of Visitor Counter with 8051 using LCD 

When the power is turned on a message (“welcome “) is displayed on LCD. The two switch attached with 8051 act as IR sensor. One sensor placed just outside the door and other placed just inside the door. If a person enter the room ,he/she cuts the first sensor and then second sensor. Then a message “No. of Visitor :01 Welcome” is displayed on LCD. If a person exit from the room ,he/she cuts the second sensor and then first sensor.Then a message “No. of Visitor :00 Thank you” is displayed on LCD. When number of visitor become zero, a message “Room is Empty” is displayed on LCD.

Basic Components

  • Power Supply
  • AT89C51 IC
  • LCD (16×2)
  • IR Sensor

 Working of IR Sensor

arrangement of ir sensor across gate in visitor counter
The sensor part consists of a ultra bright led and LDR,  LM324 and the associated passive components. The LED is placed on one side of the door and the LDR is placed on the other side of door so that the light from the LED falls directly on the LDR. As you know, the resistance of the LDR has an inverse relationship with the intensity of the light falling on it. The preset resistor R14 is so adjusted that the voltage across the LDR is below 1.5V when it is illuminated. This voltage (labelled A in the circuit diagram) is connected to the inverting input of the opamp which is wired as a comparator with reference voltage 1.5V (set using R15 and R16).Capacitor C1 is meant for bypassing noise or anything like that which may cause false triggering.Resistor R13 is meant to control the current through the LED.
When the light is falling on the LDR the voltage across it will be less than the reference voltage and so the output of the opamp remains high. When the light beam is interrupted, the voltage across the LDR goes above the reference voltage and so the opamp output goes low and it indicates a pass.

1. Circuit Diagram of Visitor Counter with 8051 using LCD

visitor counter with 8051 using lcd

1. Program of Visitor Counter with 8051 using LCD

/******************************************************
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++);
}

lcd.h

sbit rs=P3^5;
sbit rw=P3^4;
sbit en=P3^3;
sfr lcd=0x90;

void lcd_display(unsigned int x)  // lcd display fuction
{
	unsigned int i;
	lcd=x;
	rs=1;
	rw=0;
	en=1;
	for(i=0;i<100;i++);
	en=0; 
}
 
void cmd(unsigned char m)  // lcd command fuction
{
	unsigned int i;
	lcd=m;
	rs=0;
	rw=0;
	en=1;
	for(i=0;i<10;i++);
	en=0;
}
 
void lcd_ini()   // lcd initilize
{
	cmd(0x38);
	cmd(0x0e);
	cmd(0x01);
	cmd(0x06);
	cmd(0x90);
}	

void lcd_str(unsigned char *str)   // display string on lcd
{
	while(*str!='\0')  
	{
	  lcd_display(*str);
	  str++;
	}
}

PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)

download (1)

Comming soon…