Arduino PIR Sensor Wiring Diagram
Interested in home security or hobbyist electronics? The Arduino PIR (Passive Infrared) sensor is an essential component in DIY motion detection projects. It detects changes in infrared radiation levels, signaling the presence of an object within its detection range. Wire it correctly with your Arduino board, and you're well on your way to creating an effective motion detection system. Let's delve into a step-by-step guide with a comprehensive Arduino PIR sensor wiring diagram.
Before we dive into the wiring process, ensure you have the necessary components: an Arduino board (like Arduino Uno), a PIR sensor (such as HC-SR501 or AM312), jumper wires, and optionally, an LED and resistor for output verification.
Understanding the PIR Sensor
The PIR sensor has three legs: VCC (for power), GND (for ground), and OUT (for data). It has an internal 555 timer and transistors, making it highly sensitive and low-cost. To start, let's learn about its pins and functionality:
1. VCC: Connect this to the Arduino's 5V power pin to supply the sensor with the required voltage.
2. GND: Connect this to the Arduino's GND pin to provide a common ground for the circuit.
3. OUT: This pin outputs a signal when it detects motion. Connect it to one of Arduino's digital input pins.
Wiring the Arduino PIR Sensor
Now that you're familiar with the PIR sensor's pins, let's proceed with the wiring. Here's a simple and effective Arduino PIR sensor wiring diagram:
- Connect PIR sensor's VCC to Arduino's 5V.
- Connect GND to Arduino's GND.
- Connect OUT to Arduino's digital pin 2 (or any other digital pin).
- Optional: Connect an LED (positive leg to digital pin 13 and negative leg to GND via a resistor) for output verification.
Arduino Code for PIR Sensor
Use the following Arduino code to read the PIR sensor's data:
const int PIR_PIN = 2;
void setup() {
pinMode(PIR_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
if (digitalRead(PIR_PIN) == HIGH) {
Serial.println("Motion detected!");
}
}
Upload this code to your Arduino board. When motion is detected, the Arduino board sends the "Motion detected!" message via the Serial Monitor.
Mounting and Testing the PIR Sensor
Before mounting the PIR sensor, ensure the area you want to monitor is clear of obstructions. position the sensor so its lens faces the detection area. You can modify the detection range and sensitivity settings by adjusting the potentiometers on the sensor.
After mounting, test your motion detection circuit. Position an object or pass through the detection area and observe the serial monitor output. With a correctly wired and mounted PIR sensor, your Arduino board should detect and log the motion.
Congratulations! You've successfully wired and tested your Arduino PIR sensor. Now, explore more project ideas, such as integrating LEDs, buzzers, or other sensors, or even building custom home security systems. Happy tinkering!