A few days ago, I heard that Jayson Tautic (@tautic), manufacturer and purveyor of a interesting electronic prototyping goodies, had put up an interesting offering: a small PIR (passive infra red) motion detector. I’m always up for a new sensor to play with, so I ordered a pair for fun, and they arrived on Friday.
It’s a cute little package, much smaller than I expected, about 8x10mm. It has three pins, but didn’t come with a datasheet. Some queries among my buddies on the #tymkrs channel on afternet turned up this datasheet which appears to be the part. That was good enough to sort out the pinouts: the pin labeled + is the supply voltage, the pin on the opposite side is ground, and the middle pin is the sense pin. When the sensor detects motion, that pin goes high, and remains so for two seconds after the motion halts. And that’s about it.
It was tremendously simple to wire it up to an Arduino for testing. I wired the sense pin to pin 8, and then used this simple sketch…
[sourcecode lang=”cpp”]
const int pin = 8 ;
const int ledPin = 13 ;
void
setup()
{
Serial.begin(9600) ;
pinMode(pin, INPUT) ;
pinMode(ledPin, OUTPUT) ;
}
void
loop()
{
Serial.println("NO MOTION DETECTED") ;
digitalWrite(ledPin, LOW) ;
while (digitalRead(pin) == LOW)
delay(100) ;
digitalWrite(ledPin, HIGH) ;
Serial.println("MOTION DETECTED") ;
while (digitalRead(pin) == HIGH)
delay(100) ;
}
[/sourcecode]
It will turn on the LED wired to pin 13 when motion is detected, and also prints a message to the serial port. Simple.
I haven’t done any testing with this, but it appears they might be sensitive enough to detect the motion of my cat, which seems like it could be interesting. Stay tuned.
May I please call your attention to: http://www.plasma2002.com/blenderdefender/