Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Door, People, Persons, vehicle counter with 8051(89c51,89c52) microcontroller

July 27, 2019 By EG Projects

Here is a simple project on counting people, persons, vehicles or any thing passing through certain place. The place may be a gate, door, bridge or some thing else. Project could be named as object counter or visitor counter. Any thing when physically cross the barrier of our embedded system diy project will increment our counter. Counter is bidirectional means it can count/increment if the object crosses its barrier from either left or right direction. The basic idea behind it is that you don’t need to manually count persons, people vehicles etc passing through certain place. 
Early counting starts through Babbage and then counting numbers were invented, than manually people started count things. Now its digital era and we count things digitally. Previously in manually counting their are problems. One have to stand for hours to count people and vehicles passing through certain area, also he can lose data if his attention goes some where else. This project is best example of accuracy and reducing man power on extra stuff of counting.

Digital counter project requirements

  • 8051 (89c51 or 89c52) microcontroller
  • 16×2 lcd
  • crystal (11.0592 Mhz)
  • LDR (Light dependent resistor)
  • Resistor 5K
  • Bread board or PCB for circuit designing
  • Power supply
  • Potentiometer (For seeting led contrast)
  • Connecting wires​

Some tutorials related to the project. Like interfacing 16×2 lcd with 89c51 microcontroller, it working modes and operating commands. The tutorials will help you in understanding the code below. ​

Lcd 16×2 Working

Commands and Data send to 16×2 Lcd – Difference

Object/People counter with 89c52 microcontroller – Circuit Diagram

Counter values are displayed on 16×2 lcd. Lcd is interfaced with 8051 microocntroller in 8-bit mode. Data pins of 16×2 lcd are connected to Port-1 of 8051(89c51 or 89c52) microcontroller. The rs (register select) pin of 16×2 lcd is connected to Port-3 pin-5 of 8051 microcontroller. The rw (read-write) pin of lcd is connected to Port-3 pin-7 of 8051 microcontroller. The en (enable) pin of lcd is connected to Port-3 pin-6 of 89c51 microcontroller. Rest of the connections are to make 8051(89c51 or 89c52) microcontroller operational. Like apply 5v to vcc(pin 40) and vpp(pin 31). Ground pin 20. Connect crystal to pin 18 and 19. 11.0592 MHz crystal is used in the project.

89c51 digital counter sensor

Their are many techniques and pre-assembled sensors available in market for counting purpose. The most popular technique among diy embedded circuit designers is using laser light and a light dependent resistor(LDR).  Laser light is thrown on light dependent resistor from a distance.  When a person passes in between the laser and LDR setup the light stops falling on the LDR. The movement when person is in front of laser light it blocks the light and LDR laser light connection is braked. The connection is made again when the person moves away from laser light. This breaking and making of connection is interpreted by the 8051 microcntroller and is counted as 1.
Laser and LDR(Light dependent resistor) object, people, person, vehicle counter

Laser and LDR(Light dependent resistor) object, people, person, vehicle counter

The last thing in the circuit is pin 0 of Port-2. Here all the logic is created. The laser light is continuously falling on the ldr(light dependent resistor), short circuiting the circuit. The controller read it as ‘0’ or low. Now when some one passes through the way and cuts the laser falling on the Ldr. The circuit completes and controller reads it as ‘1’ or high. So when ever the light falling on the ldr is disturbed the controller reads it as 1 and increments the output. 
Door,people,person,vehicle counter with 8051 microcontroller Circuit Diagram

Door,people,person,vehicle counter with 8051 microcontroller Circuit Diagram

8051 microcontroller Object counter code

The code is simple first i included the necessary header file reg<51.h> . If you are coding in keil ide for 8051 microcontroller then this library is must to be included in your source code. Then checkconditions() function is initialized. This function is checking if the person is crossed through the path or not. Then single sbits are defined for enable , register select and read write pins of 16×2 lcd. pcount variable is initialized for connecting our logic circuit to Port-2 pin-0. Delay() function is generating some delay to be used where needed. lcdcmd() fuction is sending commands to lcd. lcddata() function is sending data to lcd. lcdint() is initializing the lcd. Then at last main function is defined. 

When you are all done by making circuit and burning hex code in microcontroller now its time to see the result. Upon starting the program you will see text “DOOR COUNTER!!!” displayed on the first line of the 16×2 lcd. On second line there is nothing. Now move your finger and cut the light falling on the light dependent resistor. You will see number displayed on the screen and ever time you cut the light the number is incremented by one.

 #include<reg52.h> void checkconditions(); sbit rs=P3^5; sbit rw=P3^7; sbit en=P3^6; sbit pcount=P2^0; unsigned int count=0; void delay(unsigned int no) { unsigned int i,j; for(j=0;j<=no;j++) for(i="0;i<=2;i++);" }

void lcdcmd(unsigned int command){
p1="command;
rw=0;
rs=0;
en=0;
delay(300);
en=1;
delay(300);
en=0;
}

void" lcddata(char data1)
{
p1="data1;
rw=0;
rs=1;
en=0;
delay(300);
en=1;
delay(300);
en=0;
}
void" lcdint()
{
lcdcmd(0x30);	delay(3000);	lcdcmd(0x30);	delay(3000);	lcdcmd(0x30);	delay(3000);
lcdcmd(0x30);	delay(3000);	lcdcmd(0x30);	delay(3000);	lcdcmd(0x38);	delay(3000);
lcdcmd(0x01);	delay(3000);	lcdcmd(0x0c);	delay(3000);	lcdcmd(0x80);	delay(3000);
}
void checkconditions(){
char ch1,ch2,ch3;
unsigned adcvalue1;
while(1){

if(pcount="=1)
{
lcdcmd(0xC0);
count++;
ch1=count/100;
if(ch1!=0)
lcddata(ch1+0x30);
delay(100);
Adcvalue1=count%100;
ch2=Adcvalue1/10;
if(ch2!=0)
lcddata(ch2+0x30);
ch3=Adcvalue1-(ch2*10);
lcddata(ch3+0x30);
delay(10000);
//lcddata(count);

while(1){
if(pcount==0)
checkconditions();
}}}}

void" main()
{
char u[]="{"DOOR" counter!!!" p1="0x00;
P2=0xFF;
P3=0x00;
lcdint();
" while(u[count]!='\0' count="0;
" delay(100000); delay(100000);
 while(1){
 checkconditions();}
}
< />mp></reg52.h>
More counter and security alarm projects using different microconrollers and sensors like PIR(passive infrared), LDR(light dependent resistor), Laser light, Ultrasonic sensor etc. Each project contains free source code and circuit diagram of the project. 

Home security with arduino uno

PIR security system over WiFi using nodemcu

Watch The project Video Here……..

Door Counter files/code

Related Articles Read More >

How to monitor pH levels in an aquarium using Arduino
TV remote hack using Arduino and IR sensor
Gesture sensor using Arduino
How to build a metal detector using an inductive proximity sensor with Arduino

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Wireless Modules
  • ADC with NRF24LE1 (Part 2/14)
  • Interrupts with NRF24LE1 (Part 3/14)
  • Power Failure Indicator in NRF24LE1 (Part 4/14)
  • Using EEPROM of NRF24LE1 (Part 5/14)
  • PWM with NRF24LE1 (Part 6/14)

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • Introduction to LUFA
  • What are the different types of integrated circuits?
  • Introduction to Wireless Modules
  • ADC with NRF24LE1 (Part 2/14)
  • Interrupts with NRF24LE1 (Part 3/14)

RSS EDABOARD.com Discussions

  • How to find 1's and 2's complement without using CMA operation in 8085 microprocessor?
  • Non-Inverting Amplifier (AC Coupled) : How to solve this circuit with lower and high frequency?
  • Electrolytic capacitor lifetime and rated voltage?
  • Syntax error in verilog
  • 2SC1971 Vs 2SC1972

RSS Electro-Tech-Online.com Discussions

  • Wirer up stereo needle
  • Learning C
  • Post some funny stuff...
  • Looking for an SOIC socket
  • QA pass
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering