Left=MS13, right=tested PIR:
So i hooked it up to the 5V output from the Arduino and connected the PIR output to one of the Arduino's digital inputs and added a LED to have a visual confirmation of motion detection:
Wrote a sketch that switches the LED and writes some text to the XBee that was also connected to the Arduino.
Code: Select all
//
// PIR motion detector with LED indicator
// Status info by XBee to PC
// 07 Oct 2009
//
#include <NewSoftSerial.h>
NewSoftSerial XBSerial = NewSoftSerial(2, 3);
int PIRpin = 4; // digital pin 4 for PIR
int LEDpin = 9; // digital pin 9 for LED
int PIRval; // PIR HIGH or LOW value
void setup() {
pinMode(LEDpin, OUTPUT); // set the LED pin as ouput
pinMode(PIRpin, INPUT); // set the PIR pin as an input
// Setup SoftwareSerial port
XBSerial.begin(9600);
// send informational message to terminal window
XBSerial.println("Setup finished.");
}
void loop() {
PIRval = digitalRead(PIRpin); // read PIR
if (PIRval == HIGH) {
XBSerial.print(millis()); // show uptime
XBSerial.println(" High!");
digitalWrite(LEDpin, HIGH); // LED ON
}
else {
XBSerial.print(millis());
XBSerial.println(" Low!");
digitalWrite(LEDpin, LOW); // LED OFF
}
delay(100);
}
Code: Select all
...
205564 Low!
205679 Low!
205793 High!
205908 High!
...
...
...
209485 High!
209601 High!
209716 Low!
209830 Low!
209945 Low!
...
From what i have seen so far, detected motion results in a high output value for about 1.5 - 2 seconds minimal. And as long as there is motion detected, the output will remain high.
In the very short time i tested this PIR, sensitivity looks very good.
Actually this is very nice; with this PIR you have almost realtime information about whether there is motion detected or not. Hook it up to an Arduino which will do the polling and for example only forward changes in motion detection.
Perhaps even add extra functionality in when to forward changes, like motion has to have a minimal time of x seconds before it is considered motion. Anything is possible.[8D]
Next thing on the list is combining a PIR and a XBee module to make the PIR wireless.
<hr noshade size="1"><font size="1">Robert
http://www.hekkers.net <i>Digit's Online Home.</i></font id="size1">