Automatic Door Opening System With Arduino

by | Mar 22, 2023 | Arduino, Basic Coding, Coding

Home » Coding » Automatic Door Opening System With Arduino

Introduction of the Project

Are you tired of fumbling for your keys every time you approach your front door? Do you wish you could easily open your door hands-free? Look no further than the Automatic Door Opening System with Arduino!

This innovative system utilizes an Arduino microcontroller to sense your proximity and automatically open your door for you. It’s perfect for those with mobility issues or anyone who wants to streamline their daily routine. Plus, it’s a fun and easy DIY project for electronics enthusiasts and beginners alike.

In this article, we’ll take a closer look at how the Automatic Door Opening System with Arduino works, the components you’ll need to build it, and how to program it for optimal performance. So let’s dive in and explore this exciting and practical application of Arduino technology!

 

Supplies

To build an Automatic Door Opening System with Arduino, we will use a PIR motion sensor, which will sense the motion of any person near the door, and accordingly, the door will open and close. Other components required are as follows:

Components

Circuit Diagram

Steps To Build An Automatic Door Opening System With Arduino

Step 1: Gather all the components on the Digital Board or Physical Table.

PIR Sensor:

Step 2: Ground terminal of the PIR Sensor is connected to the GND (Ground) pin of the Arduino.

Step 3: The power terminal of the PIR Sensor is connected to the 5V pin of the Arduino.

Step 4: Connect the Signal terminal of the PIR Sensor to the 10-number pin of the Arduino.

Micro Servo:

Step 5: The power terminal of the micro servo is connected to the 5V pin of the Arduino.

Step 6: The signal terminal of the micro servo is connected to the 2 & 12 number pin of the Arduino, respectively.

Step 7: Ground terminal of the micro servo is connected to the GND (Ground) pin of the Arduino.

Source Code

#include <Servo.h>
Servo s1, s2;
int presence = 0;
void setup()
{
Serial.begin(9600);
pinMode(10, INPUT);
s1.attach(2);
s1.write(0);
s2.attach(12);
s2.write(0);
}
void loop()
{
presence = digitalRead(10);


Serial.print(presence);


if(presence == HIGH)
{
s1.write(50);
s2.write(50);
delay(3000);
}
if(presence == LOW)
{
s1.write(0);
s2.write(0);
}
}

Explanation of the Code

1. Servo library has been declared in the beginning.

2. Then, you have to declare the object of the servo as ‘s1’ and ‘s2’ and initialize another integer variable, ‘presence’ to 0.

3. Next, the pinmode of the Arduino is configured in the setup function for input purposes by using serial.begin. We have established a with 9600 bits per second serial connection.

4. After that, we have attached pin numbers 2 & 12 of the Arduino to the servo. Initially, writing it to 0 degrees means the gates will be initially in a closed position.

5. Now, we are reading input from pin number 10 of the Arduino in the loop function, which will tell us if there is any human in motion near the door or not. We are storing the value in the presence variable.

6. After that, we use the if statement to change the direction of the servo with respect to the presence variable. 

7. We have used the write function to change the orientation of the servo. If any human passes in the range of the sensor, the gates will open.

Output

We have successfully built an Automatic Door Opening System with Arduino.

On starting the simulation, if any human is near the door, the door will open automatically, or say, if there is any motion in the range of the sensor, the servo will turn to 50 degrees.

 

More Arduino Projects>>>

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *