Day 01

Begineer

Day 12 :- Motion Detector (PIR)

Aug 13, 2026

Completed

Wiring Schematic

Arduino Code

ARDUINO / C++

Day 12 Core Training Documentation

Project Overview

The Motion Detector PIR project teaches you one of the most important concepts in security systems: detecting human movement using infrared sensing.

In this project, a PIR (Passive Infrared) motion sensor detects movement by sensing changes in infrared radiation. When motion is detected, the Arduino triggers an LED to illuminate and a buzzer to sound an alarm, creating a complete motion-activated security system.

When no movement is present, the LED and buzzer remain silent. The moment a person or object moves in front of the sensor, the Arduino instantly detects the heat signature change and activates the alarm system, providing immediate alert notification.

This project teaches PIR Sensor Operation, Motion Detection Principles, Automated Alert Systems, Sensor Sensitivity Calibration, and Security System Applications.

By finishing this project, you’ll understand how motion sensors work in security systems, burglar alarms, automatic lighting, and smart home automation devices.

Components Required

To build this circuit, collect these specific items from your kit:

Arduino Uno × 1, Breadboard × 1, PIR Motion Sensor × 1, Red LED × 1, 220Ω Resistor × 1, Passive Buzzer × 1, Jumper Wires × 5, USB Cable × 1

Circuit Connections

Step 1: Connect Ground Rail

Connect the Arduino GND pin to the negative rail of the breadboard. This creates a shared ground connection for all components.

Step 2: Connect the PIR Sensor

Place the PIR motion sensor near the edge of your breadboard. The sensor has three pins that need careful connections. Position the sensor so the lens faces outward toward the area you want to monitor.

Step 3: Connect VCC Pin

Connect the VCC (power) pin of the PIR sensor to Arduino 5V. This provides power to the motion sensor module.

Step 4: Connect GND Pin

Connect the GND (ground) pin of the PIR sensor to the breadboard negative rail. This completes the power circuit for the sensor.

Step 5: Connect Output Pin

Connect the OUT (output) pin of the PIR sensor to Arduino Pin 6. This pin sends the motion detection signal to the Arduino.

Step 6: Connect the Red LED

Put the red LED into the breadboard. Connect the long leg (Anode) to Arduino Pin 2 through a 220Ω resistor. Connect the short leg (Cathode) to the breadboard GND rail.

Step 7: Connect the Passive Buzzer

Place the passive buzzer onto the breadboard. Connect the positive (+) terminal to Arduino Pin 3. Connect the negative (-) terminal to the breadboard GND rail.

Step 8: Verify Connections

Check all sensor pins and verify the LED and buzzer connections before uploading your code.

Important: The PIR sensor requires a warm-up period of 30 to 60 seconds after power-up before it can reliably detect motion. Allow this initialization time before testing the system.

How the Arduino Code Works

Configure All Pins

In setup(), Arduino sets Pin 6 as INPUT to receive motion detection signals from the PIR sensor. Pin 2 is configured as OUTPUT to control the red LED. Pin 3 is set as OUTPUT to control the buzzer tone generation.

Read Motion Sensor Status

The Arduino continuously reads the digital signal from the PIR sensor using digitalRead(). When no motion is detected, the sensor outputs LOW. When motion is detected, the sensor outputs HIGH, triggering the alarm system.

Activate Alert System

When the PIR sensor detects motion and outputs HIGH, the Arduino immediately turns ON the red LED. Simultaneously, the buzzer generates an alarm tone using the tone() function, creating both visual and audio alerts.

Manage Alarm Duration

The LED and buzzer remain active for a preset duration, typically 5 to 10 seconds. After the alarm period expires, the system returns to standby mode and waits for the next motion event.
 

Continuous Monitoring

The motion detection cycle repeats continuously inside the loop() function. This allows the system to monitor the area constantly and respond instantly to any movement detected by the PIR sensor.

Expected Output

After uploading your code, here is what happens.

Wait 60 seconds for the PIR sensor to warm up and initialize. When initialization is complete, the LED remains off and the buzzer stays silent. Move your hand or body in front of the sensor and the red LED immediately turns on while the buzzer sounds an alarm. Stop moving and after the alarm duration expires, the LED and buzzer turn off automatically. Move again and the system activates instantly. The system continues to monitor and respond to any motion detected.

Operational Troubleshooting

Motion Not Detected :- Wait 60 seconds after power-up for sensor initialization. Move slowly in front of the sensor as rapid movements detect better than slow ones. Check that the sensor has a clear line of sight and is not blocked by obstacles.

False Alarms Occur Frequently :- Check the sensor sensitivity adjustment if your PIR sensor has a potentiometer. Move the sensor away from heat sources like heaters, sunlight, or air conditioners. Ensure the sensor is not pointed at moving objects like fans or curtains.

LED Does Not Turn On :- Verify the LED polarity and check the resistor connection. Make sure Pin 2 connects correctly to the LED and confirm the LED is receiving power properly.

Buzzer Makes No Sound :- Check the buzzer polarity and verify Pin 3 connection. Confirm that the tone() function is called in your code when motion is detected.

Sensor Output Pin Always Reads High :- Verify that the sensor is properly powered at 5V. Check the sensor output pin connection and ensure it is not shorted to power. Try repositioning the sensor away from heat sources.

What You Learned

By finishing this project, you now know :-

How PIR motion sensors detect infrared radiation changes, how motion detection systems work in security applications, how to interface digital sensors with Arduino, how to create automated alert systems, and how to integrate multiple outputs for comprehensive alerting.

Next Lesson

Congratulations on completing Stage 2: Sensors and Sound! You have mastered six essential embedded systems projects covering light detection, sound generation, distance measurement, temperature sensing, and motion detection. You are now ready to progress to more complex projects involving wireless communication, data logging, and autonomous systems