Friday, September 27, 2013

Arduino PIR Motion Sensor / Detector

Make your own Arduino motion sensor / detector.  Maybe you want something to happen when you walk into a room, like have the lights turn on, or have your theme song play whenever you enter.

This tutorial will show you how to get your to Arduino sense motion around it.

Hardware used in this tutorial:

· Motion Sensor for Arduino, with wire jumpers

· Arduino board (Uno, Mega, Duemilanove, etc.)

Instructions:

If this is your first Arduino project, first go through our “Arduino: Getting Started” tutorial.

Connections:

Use the supplied male to female jumpers to make these connections:

Motion Detector

Pin

Arduino Pin

"-"

GND

"Out"

Arduino Pin 2

"+"

+5v

Like this:

clip_image001

Here is the front view of the module:

clip_image002

Software:

Download the example motion sensor for Arduino software here, and unzip the file

/* 
    Motion sensor for Arduino, example code
    Tutorial: 
http://www.hacktronics.com/Tutorials/arduino-motion-sensor.html
    Copyright: Mark McComb, hacktronics LLC
    License:
http://www.opensource.org/licenses/mit-license.php (Go crazy)
*/

const byte ledPin =  13;    // LED pin
const byte motionPin = 2;   // motion detector input pin
byte senseMotion = 0;       // variable to hold current state of motion detector

void setup() {
  // set the digital pin directions
  pinMode(ledPin, OUTPUT);     
  pinMode(motionPin, INPUT);
}

void loop()
{
    // Now watch for burglers
    senseMotion = digitalRead(motionPin);
    if (senseMotion == HIGH) {    // burgler found!
      digitalWrite(ledPin, HIGH);
    } else {                      // no burgler, yet...
      digitalWrite(ledPin, LOW);
    }
}

or copy the blue text above to motion_sensor_for_arduino.pde file.

You will now have a folder called “motion_sensor_for_arduino”

Start the Arduino software and load the Arduino Motion Sensor example program by clicking File->Sketchbook->Open

Navigate to the motion_sensor_for_arduino folder and select the “motion_sensor_for_arduino.pde” file.

Transfer the Arduino Motion Sensor program to your Arduino board by clicking the “Upload to I/O board” button. After uploading, you should see the LED on the Arduino board light up whenever there is motion detected.

It is that simple to add motion detection to your Arduino project.

Remember, it takes about 60 seconds after you first power up the motion sensor before it stars to detect motion.

You can adjust the amount of time that the motion detector lights the Arduino LED by adjusting the potentiometer screw on the back of the motion sensor module:

clip_image003

Happy Hacking!

Based On: http://www.hacktronics.com/Tutorials/arduino-motion-sensor.html

1 comment:

Ecosens said...

Thank you for posting this excellent information..it is very useful to me..!
Click here:
Motion Sensor in Delhi