keyestudio
Share your creative ideas with us here
By Alisa | 28 March 2024 | 0 Comments

How to Use PIR Motion Sensor to Control Buzzer?

1.Introduction
 

PIR motion sensor measures the thermal infrared (IR) light emitted by moving objects. The sensor can detect the movement of people, animals, and cars to trigger safety alarms and lighting. They are used to detect movement and ideal for security such as burglar alarms and security lighting systems. In this project, we will use a PIR motion sensor and buzzer to detect sounds when people or animals approach.


2.Components Required
 

img

img

img

img

Keyestudio Plus Mainboard*1

PIR Motion Sensor*1

Active Buzzer*1

Breadboard*1

img

img

img

 

F-F Dupont Wires

USB Cable*1

Jumper Wires

 


3.Component Knowledge
 

PIR motion sensor:

The principle is that when certain crystals, such as lithium tantalite and triglyceride sulfate, are heated, the two ends of the crystal will generate an equal number of charges with opposite signs. These charges can be converted into voltage output by an amplifier. And the human body will release infrared light, although relatively weak, but still can be detected. When the PIR motion sensor detects the movement of a nearby person, the sensor signal terminal outputs a high level 1. Otherwise, it outputs a low level 0. Pay special attention that this sensor can detect people, animals and cars in motion. People, animals and cars at rest cannot be detected. The maximum detection distance is about 7 meters.


Note:

Since vulnerable to radio frequency radiation and temperature changes, the PIR motion sensor should be kept away from heat sources like radiators, heaters and air conditioners, as well as direct irradiation of sunlight, headlights and incandescent light.


Features:

  • Maximum input voltage: DC 3.3 ~ 5V

  • Maximum operating current: 50MA

  • Maximum power: 0.3W

  • Operating temperature: -20 ~ 85℃

  • Output high level is 3V, low level is 0V.

  • Delay time: about 2.3 to 3 seconds

  • Detection Angle: about 100 degrees

  • Maximum detection distance: about 7 meters

  • Indicator light output (when the output is high, it will light up)

  • Pin limiting current: 50MA


Schematic diagram:


4.Circuit Diagram and Wiring Diagram


5.Code
 

/*
PIR_control_buzzer
http//www.keyestudio.com
*/

int buzzerpin = 8;  // the pin of the buzzer
int pirPin = 3;     // the pin of the PIR motion sensor
int pirStat = 0;   // the state of the PIR motion sensor
void setup() {
 pinMode(buzzerpin, OUTPUT);     
 pinMode(pirPin, INPUT);     
 Serial.begin(9600);
}
void loop()
{
 pirStat = digitalRead(pirPin); 
 if (pirStat == HIGH)
 {            // if people or moving animals are detected
   digitalWrite(buzzerpin, HIGH);  // the buzzer chirps
   Serial.println("Hey I got you!!!");
 } 
 else {
   digitalWrite(buzzerpin, LOW); // if people or moving animals are not detected, turn off buzzers
 }
}


6.Result
 

Burn the project code, wire up and power on first. If the PIR motion sensor detects someone nearby, the buzzer will give an alarm. Click to open the serial monitor on the Arduino IDE, and you will see“Hey I got you ! !”.

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code