Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

PIR+Motion+Sensor: Detecting Movement with Arduino

Importance and Utility of PIR+Motion+Sensor

The PIR (Passive Infrared) Motion Sensor is a commonly used sensor in various applications, including security systems, home automation, and robotics. It detects movement by sensing changes in infrared radiation emitted by living beings or objects in its field of view. This sensor is highly useful for detecting human presence, triggering alarms, activating lights, and controlling other devices based on motion.

Project: Motion-Activated LED Light

In this example project, we will create a motion-activated LED light using an Arduino board and a PIR motion sensor. The objective is to turn on an LED when motion is detected and turn it off after a certain period of inactivity. This project can be used to automate lighting in areas where motion detection is desired, such as hallways, staircases, or closets.

List of Components:

  • Arduino Uno board x1
  • PIR Motion Sensor x1
  • LED x1
  • Resistor (220 ohms) x1
  • Breadboard x1
  • Jumper wires

You can find these components at [link to purchase].

Examples:

  1. Wiring the Components

Before writing the code, let's wire the components as follows:

  • Connect the VCC pin of the PIR motion sensor to 5V on the Arduino.
  • Connect the GND pin of the PIR motion sensor to GND on the Arduino.
  • Connect the OUT pin of the PIR motion sensor to digital pin 2 on the Arduino.
  • Connect the anode (longer leg) of the LED to digital pin 13 on the Arduino through the resistor.
  • Connect the cathode (shorter leg) of the LED to GND on the Arduino.
  1. Code Explanation
int pirPin = 2; // PIR motion sensor output pin
int ledPin = 13; // LED pin

void setup() {
  pinMode(pirPin, INPUT); // Set PIR pin as input
  pinMode(ledPin, OUTPUT); // Set LED pin as output
  Serial.begin(9600); // Initialize serial communication
}

void loop() {
  int motion = digitalRead(pirPin); // Read PIR sensor output

  if (motion == HIGH) { // Motion detected
    digitalWrite(ledPin, HIGH); // Turn on LED
    Serial.println("Motion detected!");
  } else { // No motion
    digitalWrite(ledPin, LOW); // Turn off LED
    Serial.println("No motion detected.");
  }
  delay(100); // Delay for stability
}
  1. Use Case: Home Security System

By expanding on this project, you can create a simple home security system. For example, you can add a buzzer or send a notification to your smartphone when motion is detected. Additionally, you can connect the Arduino to a relay module to control other devices, such as turning on lights or activating a camera.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.