I have this Zilog EPIR senor that Im trying to incorporate into a robot project of mine. Found some test code online that I am using to make sure I had it all wired up correctly.
The wiring is in accordance to this diagram:
And finall here is the sample code I am using:
int sleepModePin = 4;
int motionDetectPin = 2;
int alarmLED = 12;
int val;
void setup() {
//the sleep pin has to be active high to enable detection
digitalWrite(sleepModePin, HIGH);
}
void loop() {
val = digitalRead(motionDetectPin);
//the ePIR sensor is active low so if motion is detected the output is low
if(val == LOW) {
digitalWrite(alarmLED, HIGH);
} else {
digitalWrite(alarmLED, LOW);
}
}
It all seems to work fine when Im using an LED. It performs exactly as you would expect, the light turns on when I pass my hand near the motion sensor. However, I do not want to use this to control a light. I planned on using it to make a vibration motor (shown here) shake when motion was detected. Since the LED setup worked fine, I tried doing the exact same setup, but putting the terminals from my vibration motor in the place of the LED (resistor removed of course). With this set up, the motor never vibrates. Im puzzled as to what changed when I went from LED to motor. I made sure the motor was working, I attached each terminal to a AA battery and it did indeed vibrate. If anyone can help me figure out why this motor wont vibrate when motion is detected Id be very appreciative.