Visitor Counter Using 8051 and IR Sensor With LCD

Introduction: Visitor Counter Using 8051 and IR Sensor With LCD

Dear Friends, I have explained how to make a visitor counter using 8051 and IR sensor and displayed it in the LCD. 8051 is one of the most popular microcontroller used for making hobby, commercial applications all around the world. I have made a visitor counter with that chip.

I have used 78E052 Nuvoton microcontroller on my hardware. you can use any kind of 8051 microcontroller. The code which i have used is written in Embedded C and compiled on keil compiler.

Supplies

89C51 microcontroller

IR sensor

16x2 LCD

Step 1: Construct the Hardware

I have constructed the hardware in such a way. AS you see on the image, I have drawn the image as per the schematic of the project board which i given on the image. You can design your own circuit and modify the code.

Step 2: Program Code for Visitor Counter

#include<reg51.h> #include<stdio.h> 
sbit rs=P3^6;
sbit en=P3^7;
void lcd(char a,int b);                        
unsigned char msg[]="Counter";
char ch[4];
void delay();                                    
void counter();                               
int k;
unsigned int val;
void main()
 {
   lcd(0x38,0);
   lcd(0x0c,0);
   lcd(0x80,0);
   TMOD=0x05;                                
   counter();                                
 }
void delay()
 {
   int i;
   for(i=0;i<=2000;i++);                
 } 
void counter()
 {
   TL0=0;                                  
   TR0=1;                                
   for(k=0;k<5;k++)
     {
       lcd(msg[k],1);
     }
   while(1)
    {
      lcd(0x88,0);                           
      val=TL0|TH0<<8;                 
      sprintf(ch,"%u",val);             
      for(k=0;k<5;k++)
        {
          lcd(ch[k],1);
        }
    }
  }
 void lcd(char a,int b)
   {
     P1=a;
     rs=b;
     en=1;
     delay();
     en=0;
     delay();
   }

Step 3: OUTPUT

connect the IR sensor with the microcontroller

download the code

move an object across the IR sensor

You can observe the Object count in the LCD

click thelink for demo video

Be the First to Share

    Recommendations

    • Robots Contest

      Robots Contest
    • Micro:bit Contest

      Micro:bit Contest
    • Space Contest

      Space Contest

    Comments