PIR Sensor Arduino Alarm

Build a motion-sensing alarm with a PIR sensor and an Arduino.

  • Add Note x
  • x 15

Here's how you can build a motion-sensing alarm using a PIR (passive infrared) sensor and an Arduino.

Relevant parts
first image
thumb image 1
thumb image 2

Add Note Edit Step 1 — PIR Sensor Arduino Alarm  ¶ 

  • Gather your parts.

  • Check for -, +, and Out pins on the PIR sensor.

first image

Add Note Edit Step 2 — Wire the Arduino to the breadboard.  ¶ 

  • Connect Digital 2 (on the Arduino) to row 3 (on the breadboard), 5V to row 2, Gnd to row 1.

first image

Add Note Edit Step 3  ¶ 

  • Plug the PIR sensor into the board so that -, +, and Out connect to Gnd, 5V, and Digital 2.

  • Note: You may need to extend the pins with a stacking female header, wires, interconnect cables, etc. to fit.

first image

Add Note Edit Step 4 — Plug in the LED.  ¶ 

  • Plug the anode (often the longer leg) into digital pin 13 on the Arduino.

  • Plug the cathode (often the shorter leg, flattened side of the LED base) into Gnd.

first image

Add Note Edit Step 5 — Connect the piezo buzzer to the Arduino.  ¶ 

  • The red wire goes to digital pin 10.

  • The black wire connects to Gnd.

  • Note: These can be reversed, as polarity of the buzzer doesn't matter.

first image
thumb image 1
thumb image 2

Add Note Edit Step 6 — Launch the Arduino IDE (software).  ¶ 

  • Plug the USB cable into your computer and Arduino.

  • Set the board and port for your Arduino board.

  • Open the PIR Alarm sketch.

  • Upload the sketch to the Arduino.

first image

Add Note Edit Step 7 — Test the alarm.  ¶ 

  • Stand still or leave the room while it calibrates the infrared level reading for the room.

  • Test it by moving: the buzzer will buzz and the LED will light up.

  • Be amazed!

  • Sense movement up to 20 feet away.

  • Note: Cannot reliably detect zombies.

For more information, check out the Arduino category page.

Did you successfully follow this guide?

This guide has been completed 15 times.

Comments Add Note Comments are onturn off

Guide Add Note

All set up, but where do I find the code?

raelfuterman, · Reply

It's a PDF under Files at the top of the project. Have fun!

Goli Mohammadi,

I've uploaded the code you provided and wired everything up correctly. AS soon as it's uploaded to the Arduino Uno, the sensor goes off and doesn't acclimate the it's surrounding. It just sets it of immediately. What could I be doing wrong? Maybe bad sensor? It's brand new. :(

Brandon Turney, · Reply

Brandon, sorry for the huge delay, I didn't see your comment until now. You can change the delay time upon startup to be longer if you need. Try adding a new line as the first one in the void setup that reads: delay(5000);

That'll give you five seconds before it begins.

John Edgar Park,

hello thanks for the code

but I want to know if possible

speaker sound delay

and as I explained

nothing else connected arduino

speaker sound is triggered and

I want to take a few seconds to get out of house if

or only trigger when

active sensor

if not explain myself well

I'm a newbie

thanks

tazma, · Reply

hello

ok solved

now if possible I'd like

oriented

for the buzz just beeps

when motion is not explained either if

soner buzzer now at 5 seconds

I want to activate when motion

thanks

tazma, · Reply

hay...need your help...

how to connect arduino with gsm phone without gsm shield??

:)

eddy, · Reply