Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Door counter with 8051 (89c51,89c52) microcontroller

By EG Projects July 27, 2019

Here is a simple project for counting people, vehicles or anything passing through a certain place. Anything when physically crosses the barrier of our embedded system DIY project will increment our counter.
The 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.

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

Filed Under: 8051 Microcontroller, Electronic Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

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!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 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

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe