PIR Motion Sensor Arduino based Mini Projects with Alarm Code

PIR Motion Sensor: Arduino based Mini Project

Many people have alarms throughout the house and Alarms are very common nowadays. But what about your internal warning? For example, your siblings may be prevented from entering your room. This project will help you create a simple PIR motion sensor using the Arduino Uno board.

This project has no type of switch to stop it. The only way to stop it is to leave the installed room or stop it. This project also tells you how the tone function works.

Material Required for PIR Motion Sensor Arduino Project

In this project required three main Important Parts

1 x Arduino Uno Board
1 x PIR sensor
1 x Buzzer

PIR sensors allow you to sense motion and is mostly used to detect whether a human has moved in its range.


arduino projects


I set the frequency to 3000 Hz using these frequency alarms on the Internet, It is now time to download the program for PIR Motion Sensor Arduino based Mini Project. In the comments, you can find a description of the complete code The PR sensor is primarily a motion sensor, which determines the progress when it detects a movement, you control the time of this high state and controls the two powerful indicators displayed in the image under the sensitivity of your sensor.


This PIR Motion Sensor Arduino based Mini Project creates beep sounds when movements are detected. You can easily change the time of the beep by changing the delay time at the end of for loop.

Code for PIR Motion Sensor Arduino based Mini Projects with Alarm Code

bool isToneOn = false;
int frequency = 3000;

void setup() {
//here is our PIR sensor
pinMode(2, INPUT);
//here is our buzzer
pinMode(3, OUTPUT);


void loop() {
//when PIR sensor gives us HIGH it means that it detects movement
if(digitalRead(2) == HIGH){
//we will turn on alarm for 15 seconds
//we are using tone() so we can control frequency of our beep sound
//to turn tone off we have to use noTone()
//if you want to change frequency of tone you can do it in the variable
//on the top of the code
for(int a = 0; a < 30; a++){
isToneOn = false;
//3 means our pin where buzzer is connected
tone(3, frequency);
//we have to change this variable to true, we have to know
//when to turn buzzer on and when to turn it on
isToneOn = true;
//delay 0.5 second, you can change this value so it will
//beep slower or faster


Leave a Comment