Go Down

Topic: pir sensor on-time (Read 756 times) previous topic - next topic

kaporal_p

Jul 26, 2011, 07:02 am Last Edit: Jul 26, 2011, 07:33 am by kaporal_p Reason: 1
Hello,

I'm trying to trigger a servo with a parallax pir sensor http://www.robotshop.com/ca/content/PDF/pir-sensor-documentation-v1-2-555-28027.pdf. I'm also using the VarSpeedServo library.

Also, I'm using an Arduino mega 2560.

I modified some code I took from the Make magazine website http://make-documents.s3.amazonaws.com/fv1fYSLfy6QRgANM.pdf

I want the servo to start from a position, rotate to another position, wiggle a little and then come back to it's initial position. This is ok.

Now everything is almost fine.

Here's my problem; I install everything, upload the code and watch as the servo is triggered by the movement of my hands. nice, but then, the sensor seems to stay activated for about 3 seconds before shutting down. And if I keep moving, it just never shuts down, so the sequence is done once and if I keep moving it never gets to be triggered again.

Since the sensor will be in a crowded space, I would like it to be reset as soon as the action is over so it can start again.

I read something about these sensors saying that they work with a resistor that needs to go below a certain value to reset. Is that so? And if so, is there a way around it?

thanks in advance,


I just thought about pull-down resistors, could it solve my problem if I hook the sensor with that? I'll try it. (10 min. later)Well it didn't change the behavior of the setup, though I think it's better practice to kook it up this way.

here's my code

Code: [Select]



// Uses a PIR sensor to detect movement, buzzes a buzzer
// more info here: makeprojects.com/Project/PIR-Sensor-Arduino-Alarm/72/1
// email me, John Park, at jp@jpixl.net
//based upon:
// PIR sensor tester by Limor Fried of Adafruit
// tone code by michael@thegrebs.com

#include <VarSpeedServo.h>

VarSpeedServo myServo[1];
int ledPin = 13;
int inputPin = 22;
int pirState = LOW;
int val = 0;


void setup() {
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
myServo[1].attach(10);
Serial.begin(9600);
}

void loop() {
val = digitalRead(inputPin);
if (val == HIGH)
{
digitalWrite(ledPin, HIGH);
myServo[1].slowmove(128, 120);
delay(100);
myServo[1].slowmove(110, 85);
delay(100);
myServo[1].slowmove(128, 85);
delay(100);
myServo[1].slowmove(110, 85);
delay(100);
myServo[1].slowmove(128, 85);
delay(100);
myServo[1].slowmove(47, 85);

if (pirState == LOW)                   // we have just turned on
 {  

 pirState = HIGH;
 }
}
else
{
digitalWrite(ledPin, LOW);
myServo[1].slowmove(47, 85);
if (pirState == HIGH)
 {
 pirState = LOW;
 }
}
}



CrossRoads

Quote
I read something about these sensors saying that they work with a resistor that needs to go below a certain value to reset. Is that so? And if so, is there a way around it?

Sure - find a schematic for your sensor, identify the resister, and change it.
Or trace the board connections out by hand, draw it up, post it, and we can help identify the resister.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

kaporal_p

Hey,

I just realized I had other PIR sensors with a little orange dial screw exactly meant for ajusting the delay.... hmmm

but, you think it would be possible to insert a potentiometer on the other non-adjustable ones?

that would be nice, hacking the hacking hardware!

How to know which resistor I need to replace?

Go Up