Pages: [1]   Go Down
Author Topic: adding a time interval to a PIR sensor  (Read 936 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
Some of you may remember I wrote in a while ago about activating a 35000V stun gun with a PIR sensor using an UNO.  I've got it all working, but can't seem to drop the amount of time the stun gun fires below 4 seconds.  Does anyone have any suggestions as to how to go about doing this?
Thanks

Motion detected= LED on for 1sec, 2sec, 3sec.......etc.....
no motion LED off
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25861
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, we can't see your code or any details of your project, so suggestions would be "post it".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Red Sea, Saudi Arabia
Offline Offline
God Member
*****
Karma: 12
Posts: 579
..On The Red Sea
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

If the sensor is like this one:
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=173

That little orange pot is a minimum time when fully Counter Clockwise.  But that may still be too long??

So, in code, wait for the sensor to come on, fire the Whatever for however long you want, then wait for the sensor to go OFF, then repeat??
Logged

Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was offered this suggestion in the past and used this to get everything up and running
http://www.ladyada.net/learn/sensors/pir.html

The only alteration I made that enables some control over the gun firing time is an added  delay(10); as seen below (this allows for the 4 sec. firing time)
/*
 * PIR sensor tester
 */
 
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status


void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}
 
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
   
    digitalWrite(ledPin, HIGH); // turn LED ON
    delay (10);
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
      delay (10);
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}

Does the PIR sensor put out too much power to drop the time?
is that a silly question?  I'm a novice at best when tackling these issues.

Thanks all
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25861
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does the PIR sensor put out too much power to drop the time?
is that a silly question?
It could be - what does it mean?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe the PIR has a default refractory period which results in the minimum 4 second firing time for the gun.  How can I alter that?
Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 642
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess what you need is explained in the ladyada article. (Changing pulse time and timeout length)

The Pir sensor works with two intervals, the time the output stays high after detection and the time it waits before it starts detecting again. Those are controlled by capacitor and resistor. By changing the values of the capacitor/resistor of the specific interval you can make it longer/shorter. 
Logged

Pages: [1]   Go Up
Jump to: