Pages: [1]   Go Down
Author Topic: pir sensor on-time  (Read 724 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:


// 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;
  }
 }
}


« Last Edit: July 26, 2011, 12:33:54 am by kaporal_p » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Jump to: