How to Build a Simple Arduino Motion Sensor That Alerts You When Someone’s at the Door

How to Build a Simple Arduino Motion Sensor That Alerts You When Someone's at the Door

Building a simple motion sensor with Arduino is a great electronics project for beginners. With just a few common components, you can create a device that detects movement and alerts you when someone approaches your door. Here's a step-by-step guide to building your own Arduino motion sensor.

What You'll Need

Here's a list of the components you'll need to build the motion sensor:

How It Works

The main component of this project is the PIR motion sensor. This sensor detects infrared radiation that is emitted by warm objects such as people and animals.

When something moves within the PIR sensor's detection range, it detects the change in infrared radiation and sends a HIGH signal to the Arduino. We can detect this state change in the Arduino code and activate the buzzer to sound an alarm.

The buzzer is connected to a digital pin on the Arduino and turns on when it receives a HIGH signal. This is how it alerts you when the PIR sensor detects motion.

Circuit Diagram

Here is the circuit diagram showing how to connect the components:

The PIR sensor has three pins - VCC, GND, and OUT. Connect VCC to 5V and GND to ground. The OUT pin connects to a digital pin on the Arduino.

The buzzer positive lead connects to Arduino pin 11 through a 220 ohm resistor. The negative lead goes to ground.

Code

We need to upload this Arduino sketch to monitor the PIR sensor and activate the buzzer when motion is detected:

```cpp
const int pirPin = 3; // PIR Out pin
const int buzzer = 11; //buzzer pin

void setup() {

pinMode(pirPin, INPUT);
pinMode(buzzer, OUTPUT);

}

void loop() {

if(digitalRead(pirPin) == HIGH) {

tone(buzzer, 1000); //send 1KHz sound signal

delay(500);        //delay 500ms

noTone(buzzer);     //stop sound

}
else{

noTone(buzzer);

}

}
```

We set the PIR sensor pin as an INPUT and the buzzer pin as an OUTPUT. In the loop(), we continuously check if the PIR pin is HIGH. If motion is detected, we activate the buzzer, delay for some time, and then turn it off. This will create an beeping alarm sound.

Construction

Follow these steps to assemble the circuit:

  1. Insert the Arduino into the breadboard. Connect the positive lead of the 9V battery to the Vin pin and the negative lead to GND to power the Arduino separately.

  2. Place the PIR sensor on the breadboard. Connect VCC to 5V, GND to ground, and OUT to digital pin 3.

  3. Connect the 220 ohm resistor from pin 11 to the buzzer positive leg. The negative leg connects to ground.

  4. Upload the code to the Arduino.

  5. Open the serial monitor and check that the buzzer beeps when you move in front of the PIR sensor.

  6. Disconnect the Arduino from your computer. Power it from the 9V battery.

That's it! Your motion sensor is ready. Place it near your door to detect anyone approaching.

Usage Tips

With this simple Arduino motion sensor project, you can build an effective security alert system on your own. It's a great STEM learning experience as well!