Hello all,
I'm new to elecronics/Arduino world and have a few questions about my PIR sensor. I have the SE-10 PIR sensor from sparkfun and I'm trying to set it up as a trigger for my camera. I would like to use it to catch birds or prey swopping down to catch bait.
I am currently using the setup from this page, and also using the code as a guide.
My first question involves I problem that when I run my code, sometimes it seems like the sensor get's "stuck" in the on position after it's initial trigger. I've noticed that the shorter the delay between my analogread's the more likely this occurs. Other times it almost seems random to me. Is this normal for PIR sensors? Do the need time to get rid of a charge or something similar? I've tried tweaking the delay and assigning the int. a high value after the intial trigger to try and avoid this problem without luck. I would like the sensor to trigger as soon as motion happens. Anyone have an ideas on how to do this?
My second question involves the difference between analog and digital input with PIR sensors. I've looked at other sites using a PIR to trigger a camera, and they are use digital in, instead of analog in. I've tried using the digital input with my PIR but it didn't seem to work at all. Are PIR sensors made specifically to be either digital or analog? Or can they be used in both methods? Here are the setups I've tried for digital Input.
Here's the code I'm currently trying.
int alarmPin = 0;
int alarmValue = 0;
int ledPin = 13;
void setup () {
pinMode(ledPin, OUTPUT);
pinMode(alarmPin, INPUT);
Serial.begin (9600);
delay (2000); // Allow time for sensor to calibrate
Serial.print ("SensorReady");
}
void loop (){
alarmValue = analogRead(alarmPin);
//If motion is detected
if (alarmValue < 100){
Serial.print ("Motion!");
digitalWrite(13,HIGH); //Turn LED for visual cue that it detected motion
alarmPin = 1000; //Set the value to try and avoid it from continually going off?
delay(200);
digitalWrite(13,LOW);
delay(2000); //Allow time for it to reset?
}
delay(100);
Serial.println (alarmValue);
}