Arduino Projects: PIR Motion Sensor

Alarms are very common nowadays, a lot of people have alarms in the whole house. But what if you want your internal alarm? For example, you may want to stop your siblings from entering your room, this project will help you build a simple PIR motion sensor using the Arduino Uno board.

This project won’t have any type of switch to turn it off so the only way to stop it is to get out of the room where it is installed or turn down the power. This project will also provide a glimpse of how the tone function works.

Parts needed

You will need just 3 main parts:

What is a PIR sensor?

passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view.


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

PIR sensor project with Arduino

First thing we have to do, before uploading the program is getting the connections ready. You will need 5 Jumper wires to connect everything, all of these wires should have male-female connectors.

Now it’s time to upload the program to Arduino. In the comments, you can find explanation of the whole code. I set the frequency to 3000 Hz because I found on the internet that most alarms use this frequency. The PIR sensor is basically movement sensor so whenever it detects movements, it sets OUT to HIGH, you can control the time of this HIGH state and the sensitivity of your sensor with the 2 potentiometers shown on the image below.

This project creates beep sounds (work similar to blink but with buzzer instead of an LED) when movements are detected. You can easily change the time of the beep by changing the delay time at the end of for loop.

The Code

So as you can see we use tone() in this code, how does it work?

tone([pin_number], [frequency]);

In our case we use pin 3 and 3000 Hz of frequency, so for us this function will looks like:

tone(3, 3000);

There is also an option to add time at the end so it looks like this:

tone(3, 3000, 1000);

The example above will produce a sound of 3000 Hz on pin 3 and this sound will last for 1 second. So it works the same as this:

tone(3, 3000);

But it is shorter.
So let’s see how the alarm system works.

You might also like:

Leave a Comment