Report for Pir Motion Sensor With Arduino Code
Report for Pir Motion Sensor With Arduino Code
Project Title:
Implementation of PIR Motion Sensor with Arduino
Objective:
The primary objective of this project is to create a motion
detection system using a Passive Infrared (PIR) sensor
interfaced with an Arduino microcontroller. The system should
be able to detect motion within its range and trigger appropriate
actions, such as turning on lights, activating an alarm, or
sending notifications.
Abstract:
Schematics:
Assemble the parts with the help of a schematics:
Implementation Steps:
1. Hardware Setup:
• Connect the VCC pin of the PIR sensor to 5V on the
Arduino.
• Connect the GND pin of the PIR sensor to GND on the
Arduino.
• Connect the OUT pin of the PIR sensor to a digital pin
(e.g., Pin 2) on the Arduino.
2. Arduino Sketch:
• Initialize the digital pin connected to the OUT pin of the
PIR sensor as an input.
• Set up the Arduino to monitor the state of the PIR sensor's
output.
• When motion is detected (i.e., the output of the PIR sensor
goes HIGH), trigger an action (e.g., turning on an LED).
• Optionally, add a delay to prevent repeated triggering for a
specified period.
3. Testing and Calibration:
• Upload the Arduino sketch to the microcontroller.
• Place the PIR sensor in the desired location with an
appropriate field of view.
• Adjust the sensitivity and timing settings of the PIR sensor
if necessary.
• Test the system by moving within the sensor's detection
range and observe the response.
4. Integration and Expansion:
• Integrate the motion detection system with other devices
or systems as needed.
• Implement additional functionalities, such as sending
notifications to a smartphone or recording data when motion is
detected.
• Consider adding features like a delay timer to control the
duration of the triggered action.
void setup() {
pinMode(led, OUTPUT); // initalize LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
Serial.begin(9600); // initialize serial
}
void loop(){
val = digitalRead(sensor); // read sensor value
if (val == HIGH) { // check if the sensor is HIGH
digitalWrite(led, HIGH); // turn LED ON
delay(100); // delay 100 milliseconds
if (state == LOW) {
Serial.println("Motion detected!");
state = HIGH; // update variable state to HIGH
}
}
else {
digitalWrite(led, LOW); // turn LED OFF
delay(200); // delay 200 milliseconds
if (state == HIGH){
Serial.println("Motion stopped!");
state = LOW; // update variable state to LOW
}
}
References:
Conclusion:
In conclusion, this project successfully demonstrates the
implementation of a motion detection system using a PIR
sensor and Arduino microcontroller. By following the outlined
steps, users can create a versatile and customizable motion
sensing solution suitable for various applications, including
home security, automation, and environmental monitoring.
Further enhancements and integrations can be made based on
specific project requirements and desired functionalities.