Hey everyone!
Today I will be explaining you about my new COVID-19 project. This project is about practicing social distancing more effectively with an automatic door control system, and will be helpful in public places such as Malls, supermarkets, railway station, ticket counters and other places where queueing is essential. The World Health Organisation, WHO, has advised people to practice social distancing (staying away from people for at least one metre) to prevent the spread of COVID-19 disease. In this project, the distance between the laser diodes are modelled as 1 m. Read on further to learn how I did this project.
Hardware components used in this project
- Arduino Mega 2560
- USB Type A/ B cable
- Breadboard power supply module - 3.3V/ 5V
- Solderless Breadboard - Full+
- Laser diodes (x5)
- Photoresistors/ LDR (x5)
- Resistors (x5) - 10kΩ
- Ultrasonic sensor module (HC-SR04)
- IR tracking sensor module
- TowerPro Micro servo motor (x2) - SG90
- LCD display module with I2C interface - 16x2
- Male/ Male Jumper wires
- Female/ Male Jumper wires
- Regulated power supply
*Note: I have used the breadboard power supply module to prevent the components from drawing out voltage from the microcontroller board.
Connections
Laser Diodes
- 01 - D25
- 02 - D27
- 03 - D29
- 04 - D31
- 05 - D33
Light Dependent Resistors
- 01 - A0
- 02 - A1
- 03 - A2
- 04 - A3
- 05 - A4
LCD display module with I2C interface
- GND - Ground
- VCC - 5V
- SDA - D20
- SCL - D21
TowerPro Micro servo motor SG90
- S (Barrier) - D9
- S (Door control) - D10
- (+) (Red wire) - 5V
- (-) (Black/ Brown wire) - Ground (GND)
Ultrasonic sensor module (HC-SR04)
- VCC - 5V
- Trig - D5
- Echo - D4
- GND - Ground
IR tracking sensor module
- S - D6
- (+) - 5V
- (-) - Ground
How this project works (Explanation of the codes)
Now, we will be looking at how this project works. You can easily deduce the codes by reading this section carefully. For this project, you will be needing the LiquidCrystal_I2C, Servo, and Wire libraries. The Servo and Wire libraries are inbuilt but the LiquidCrystal_I2C library needs to be downloaded/ installed. You can download the library from this github repo.
You would also need the I2C scanner to get the I2C address of your device. You can get the codes for the I2C scanner from this Arduino site.
Create two array functions named LDR and Laser, respectively. Add the respective pin values in the arrays. Create a LiquidCrystal_I2C object interface by using the LiquidCrystal_I2C function. Name your object as lcd and the parameters will be your device's I2C address, number of columns and number of rows. Define the trig and echo pins and create two servo objects using the Servo syntax. Name one servo object as Barrier and the other as Door, as one servo motor will control the barrier on the outside and the other one will be controlling the door on the inside of the premises. When you are replicating this system in real life, you will need to replace the servo motor controlling the door with a solid state relay module. The solid state relay module will control the motors operating the automatic sliding doors.
Create a variable for your IR sensor and another variable to store the output of the sensor. Create variables named count and distance. The count variable will be used to calculate the number of people standing in the queue while the distance variable will be used to used to store the distance calculated. Create a variable named duration using the 'long' datatype.
Within void setup( ), call pinMode( ) to configure the pins stored in the Laser and Trig pin as OUTPUT. The pins stored in the LDR array, the Echo pin and sensor should be configured as as INPUT. Use the attach ( ) function with the respective servo objects as syntax to declare that that barrier is connected to D9 and door is connected to D10. Set the initial position of the servos to 0 using the write( ) function and their respective object names as their syntax.
Within void loop ( ), create variables to store LDR values. There are different types of LDRs, so make sure to measure the values produced by each LDRs when the laser diode is shone on them and when it's not. You will need the following code to test each LDR.
Set the trig pin LOW for 5 microseconds before setting it HIGH. Set it LOW after 10 microseconds. Calculate the duration using the pulseIn function and store the value in the 'duration' variable. The pulseIn function will calculate the time taken for the ultrasonic pulse emitted by the trig pin to reach the echo pin. The echo pin will be HIGH when it receives the ultrasonic pulse. To learn about how the ultrasonic sensor module works, please visit this website.
Divide the duration by 2 and multiply it by the standard speed of sound in air. Divide the result by 10,000 to calculate the distance in cm. Store this value in distance variable. If the distance ( from the ultrasonic sensor module) is within 0 and 10 cm, the value stored in the count variable must increase by 1, and the servo motor must turn 100 degrees before turning back to 0 after 5 seconds. If value stored in the count variable is 5, then the servo motor must not turn and there should be no change in the count variable.
The IR tracking sensor sends a LOW signal to the microcontroller if an object is detected within 2 cm away from the IR sensors. So, the output value of the IR tracking sensor is LOW, the value stored in the count variable must decrease by 1 and the servo motor must turn 70 degrees. The servo motor will be connected to the door in such a way that if the servo motor rotates, the door will be pulled open. After 5 seconds, the door must be closed again.
The LCD display module must display the number of people standing in the queue and the slots which are occupied. For example, if the number of people standing in the queue is 1 and no slots are occupied, then it means that the person is not standing in the correct position and therefore not following the social distancing rules properly.
Watch the YouTube video in the last section of this page to understand how this project works. The laser diode beam will fall right on the photoresistor surface. The person has to stand in the correct position and block the beam. If the light is no longer shown on the LDR surface, then the LCD display module must show that slot 1 is occupied. Id the person moves away from this position, the light will be shone on the surface again and the slot will no longer be occupied.
Final Look
If anyone has any questions or suggestions about this project, please feel free to comment below or send me an email at arduinoprojectsbyr@gmail.com. Please do not send me any email requesting the full codes.
Comments
Post a Comment