Project tutorial
Automatic Door and Counter Prototype

Automatic Door and Counter Prototype © GPL3+

The project acts as an automatic door opener for an establishment then counts up or down the customers that went in and went out.

  • 9,971 views
  • 1 comment
  • 21 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)

About this project

The project is composed of different common components like the servo motor, ultrasonic sensor, and an output LCD Display. The complete project works in the way that all movements detected on the left door, counts the counter up, making it say that a specific number of person is inside the establishment, on the other hand, counting down signifies that this sum of persons have left the establishment

The project first planned. Dimensions were written out and the mechanism was also drawn. The task was to emulate the person counter for establishments in real life.

Housing for the Project

1. We got some illustration boards and hard cardboards then trimmed it to the exact dimensions as displayed above.

2. The trimmed boards were placed together using a Glue Gun.

3. Once the boards are shaped like a building, we then glued a stick to the Servo's Arm. The stick will act as an extension to the servo's arm that controls the opening and the closing of the doors.

4. After attach the servos to the backside of the housing with Hot Glue.

5. Test if the stick and servo movements are precise.

6. Attach the LCD on the front side of the board.

7. Attach a Ultrasonic Sensor on one side of the small roof deck like structure and then attach the other inside. Make sure that you measured the distance between the floor and the ultrasonic sensor so that the sensing input will be assured.

Wiring

1. Wire the LCD first to a breadboard hidden inside the Housing.

2. Connect the Ultrasonic Wires also to the Breadboard.

3. The Servo Wire will go directly to the Arduino Mega 2560.

4. After wiring do a test run of the program

5. Debug the code depending on your build

#Note: The hot glue used on the Servo sometimes gets unglued due to the repetitive movement of the Servo. You might want to check them every once in a while if they are still glued

The final look of the project after we presented it to our professor.

The IPO Diagram displays the basic hardware needs of the project.

Code

Automatic Door and CounterC/C++
//Adds libraries needed for the project
#include <Servo.h>
#include <NewPing.h>
#include <LiquidCrystal.h>

//defines constants for the pin layout
#define trigPin1 19
#define echoPin1 20
#define trigPin2 23
#define echoPin2 24
#define maxd 50
#define doorSensor 2

//lcd as variable for LiquidCrystal function
LiquidCrystal lcd(36,38,40,42,44,46);

//variables for telling time in Ultrasonic Sensing
long duration, distance;
int pinged;

//created variables to hold servo function
Servo myservo;
Servo myOtherServo;

//variable for counting persons
int incoming = 0;
int outgoing = 0;
int inside = 0;

//Newping sonar array containg 2 various ultrasonic sensor pin config
NewPing sonar[doorSensor] = {
  NewPing (trigPin1, echoPin1, maxd), // NewPing setup of pins and maximum distance.
  NewPing (trigPin2, echoPin2, maxd) // NewPing setup of pins and maximum distance .
};

void setup(){
  //Start Serial
  Serial.begin(9600);

  //Initiate LCD
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Hello");

  //attach pins to servos
  myservo.attach(9);
  myservo.write(0);
  myOtherServo.attach(10);
  myOtherServo.write(80);
//  attachInterrupt(digitalPinToInterrupt(20),openEnter,RISING);
//  attachInterrupt(digitalPinToInterrupt(21),openExit,RISING);
}
void loop(){

  printToLCD();
  getPing();
//  derf = incoming;
}

void getPing(){
  delay(50);                      // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  unsigned int uS = sonar[0].ping(); // Send ping, get ping time in microseconds (uS).
//  Serial.print("Ping1: ");
  pinged = uS / US_ROUNDTRIP_CM;
//  Serial.print(pinged); // Convert ping time to distance in cm and print result (0 = outside set distance range)
//  Serial.println("cm");

  if(pinged < 8){
    openEnter();
    outgoing++;
  }
  if(pinged>8){
    closeEnter();
  }

  delay(50);                      // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  uS = sonar[1].ping(); // Send ping, get ping time in microseconds (uS).
//  Serial.print("Ping2: ");
  pinged = uS / US_ROUNDTRIP_CM;
//  Serial.print(pinged); // Convert ping time to distance in cm and print result (0 = outside set distance range)
//  Serial.println("cm");
  if(pinged < 10){
    openExit();
    incoming++;
  }
  if(pinged>10){
    closeExit();
  }

}

void openEnter(){
  myOtherServo.write(0);
  delay(10);
  myOtherServo.write(80);
  delay(100);}
void closeEnter(){
  myOtherServo.write(80);
  delay(10);
  myOtherServo.write(0);
  delay(100);}
void openExit(){
  myservo.write(80);
  delay(10);
  myservo.write(0);
  delay(100);
  }
void closeExit(){
  myservo.write(0);
  delay(10);
  myservo.write(80);
  delay(100);}

void printToLCD(){
  if (inside == 0){
//    delay(100);
    closeEnter();
    
    }  
  inside = incoming - outgoing;

   if(inside < 0){
    closeEnter();
    delay(500);
    outgoing = 0;
    incoming=0;
    myOtherServo.attach(54);
    inside = 0;}
  if(inside == 1){
    myOtherServo.attach(10);}
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Customer Inside: ");
  lcd.setCursor(0,1);
  lcd.print(inside);   
  Serial.println(inside);
}

Custom parts and enclosures

Automatic Door and Counter
Schematic%20diagram

Schematics

Automatic Door and Counter
Whenever something is detected by the ultrasonic the door will open, the left door counts up while the right door counts down
Actual

Comments

Similar projects you might like

RFID Based Automatic Door System

Project showcase by Robodia Technology

  • 35,812 views
  • 20 comments
  • 97 respects

RFID Door Access Control with Counter

Project tutorial by sarful

  • 2,050 views
  • 0 comments
  • 6 respects

Door Lock System with Arduino

Project showcase by jayesh_nawani

  • 20,059 views
  • 2 comments
  • 16 respects

Automatic Sliding Door for the Garage

Project tutorial by DVDMDN

  • 15,842 views
  • 37 comments
  • 68 respects

Dooreo - The Alexa Powered Automatic Door Opener

Project tutorial by Keith Caskey

  • 2,952 views
  • 0 comments
  • 13 respects

How to make Arduino based Automatic Door Opening

Project tutorial by vijendra kumar

  • 19,836 views
  • 6 comments
  • 15 respects
Add projectSign up / Login