Picture of Arduino Basics: PIR Sensors
Welcome to the next installment of Arduino Basics!

This instructable will teach you how to use a PIR sensors with the arduino, and we wil build a simple motion detector!

Remove these adsRemove these ads by Signing Up

Step 1: Supplies

Picture of Supplies
For this instructable you will need the following:

1 arduino (with protoshield to make life easy)
1 LED of any color
1 PIR sensor from Parallax (you can find these at most radio shacks)
Solid wire to hook it up

Step 2: Setup

Picture of Setup
The wiring is pretty simple, the PIR sensor has screen printed: + - out

Hook the + to 5v, - to ground and out to pin 7

The take the LED and put power to pin 8 and ground to ground.

If its confusing, take a look at the pictures!
ibenkos2 months ago

how do i change the led to an 5v relay? so that when its movement the relay is high. and good project :)

GregM8 ibenkos1 month ago

It's simple. On a 5 volt relay (and any relay for that matter) there are typically 3 pins: VCC, IN and Ground. Connect the "In" pin on your relay (signal) to whatever output pin you selected on your Arduino . In this demonstration, it's pin 13. Done and done! :-)

ibenkos GregM818 days ago
yhanks ;)
sasaakra1 month ago
I want a code to activate the PIR sensor just if a motion exists for 25 secs continuously
GregM8 sasaakra1 month ago

Usually on PIR sensors (like the one in the link) there are trim pots, so you can adjust the amount of time you want to keep something on (25 seconds) by turning the trim pot clockwise or counterclockwise.

asachs01 made it!2 months ago

Franzy, just wanted to say that this was great, quick, and easy to use. I managed to get this working on a Spark core. Used your code (just changed the pin #'s to pirPin 0, ledPin 1), and worked like a charm. Thanks a ton!

Photo on 1-28-15 at 11.02 PM.jpgPhoto on 1-28-15 at 11.02 PM #2.jpgPhoto on 1-28-15 at 11.02 PM #3.jpg
AsadB4 months ago

Hi, If there is complete darkness will the PIR still work?

StraydogEOD AsadB3 months ago

Yes, PIRs work off of an infrared grid setup. Think of it like looking for changes in "heat" across a bunch of zones (not 100% accurate but close enough to get the point of how it works). Light is irrelevant.

JahFyahh3 months ago
I like to move it move it
pengocha4 months ago
Very good tutorial, made it and also added smoke alarm. Now it's time for the next step in my project, getting notification when triggered. Any links to tutorials to do this? I've read in the comments something about pushing box. Any examples or instructions maybe?
Fission Chips5 months ago

Thanks for sharing this! Very helpful for me.

pcame5 months ago
Yo utilice un sensor PIR como interruptor para el baño. Las manos húmedas son peligrosas, cuando no se tiene interruptor diferencial. Tiene una aprobación de 8/10 en mi casa, se resisten al cambio. Saludos
how do you get this to send a txt message?
I have made a motion activate camera and I am looking to get it to send me a text message or email when a picture is taken...any thoughts?

I know this was posted quite some time ago, but in case you are still wondering about how to get a txt or email, you will need an ethernet controller. With an ethernet controller, you can utilize the internet and send either an email or a txt message. This is done with the arduino, the ethernet shield, the sensor for triggered input, and an external program to interface with the signal from the arduino. I use pushing box. Hope this helps.

android adk is your friend. if you are into getting into app design you can do it very cheap with a bluetooth adapter
Praveens8 months ago


robmawe9111 months ago
Oliverhall12 months ago

Nice tutorial!

You can get the hc-sr501 PIR motion sensor for cheap here:

cityboy11 year ago
What should the output voltage for the LED be. My LED has about 1Volt, not enough to turn it on, anybody with thoughts.
its a nice project sir and very impresive. but sir' i have a question ahm im working with a project that uses wireless senors for security systems with an addressable alarm. can you tech me how these things well be built?
As frenzy has not replied yet, I am already going to ask you to be a bit more specific. Are you interested in just connecting wireless sensors or in building the entire system. In that case, what do you mean with 'adressable alarm'.

Just a question out of interest (forgive me if I am completely off): are you by any chance Filipino? :-)
Going to do that on my pc. Just have to try it.
bertus52x114 years ago
Did you get a new identity recently, or is this your standard Arduino outfit?
Anyway, always good to read the basics...
No you got it wrong you see he was trying to make arduinos less nerdy had the opposite affect :I
frenzy (author)  Ghost Wolf4 years ago
>.> that's was she said

(see i can come up with great comments too)
frenzy (author)  Ghost Wolf4 years ago
Sooooooooooo you like driving people crazy?
Mmm, on second thoughts, I guess you're right!
It's a great project if you can make light up sunglasses though
account3r24 years ago
if you are using fritzing, can you send me the download for the pir sensor?
frenzy (author)  account3r24 years ago
there is no download although adafruit has one in her fritzing tutorials.

i just used the basic component with 3 pins and labeled it
lynne1234 years ago
Hey frenzy,
Great tutorial - very well explained.
I could see how a heat sensor and arduino could be used for a project I have been working on. I got the parts but am woefully underexperienced to put it together. I am trying to get a thermal array sensor to run a small motor.
I'm stuck. Got any suggestions on where to go for help?
account3r24 years ago
are you using fritzing?
Yes he is.
maewert4 years ago
Do you recommend we put a 220 ohm resistor between pin 8 and the LED to limit the current?

Best Wishes
frenzy (author)  maewert4 years ago
If you want to be the most correct about it yeah. I didn't and it probablly won't blow the led out but for something more precise, definitely.
jensenr304 years ago
Nice new glasses! awesome tutorial too!