Garden Sentry

My thoughts...

I have a garden, a handful of PIR motion sensors, and a lot of rabbits. Here is what I would like to do...

  1. Use the PIR sensors in an array
  2. whichever sensor/sensors detects motion, trigger a solenoid valve to shoot a blast of water in that direction.

I can do it with one sensor/one valve. How do I do it with multiples?

My wife suggested just using a fence, but where is the fun in that???

Thanks.

mewhalen:
My thoughts...

I have a garden, a handful of PIR motion sensors, and a lot of rabbits. Here is what I would like to do...

  1. Use the PIR sensors in an array
  2. whichever sensor/sensors detects motion, trigger a solenoid valve to shoot a blast of water in that direction.

I can do it with one sensor/one valve. How do I do it with multiples?

My wife suggested just using a fence, but where is the fun in that???

Thanks.

Irrigation sprinklers already exist to do what you are planning, but where is the fun in that? If you already have it working, just use more pins on your Arduino. Add program logic to watch the new pins as well as the one you are currently watching.

Paul

dont listen to your wife

yeah, I know I can repeat the code for more sensors and loop through it, but is there a more efficient way? I was thinking that having the PIR sensors in an array and then reading the state of the sensors in the array and triggering the valves would be better, but I'm not sure how to do that. Thoughts?

My code, (which I lifted from author: Kristian Gohlke) is below...

int calibrationTime = 30;

long unsigned int lowIn;

long unsigned int pause = 5000;

boolean lockLow = true;
boolean takeLowTime;

int pirPin = 2;
int valvePin = 13;

void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(valvePin, OUTPUT);
digitalWrite(pirPin, LOW);

Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}

void loop(){

if(digitalRead(pirPin) == HIGH){
digitalWrite(valvePin, HIGH);
if(lockLow){
lockLow = false;
Serial.println("---");
Serial.print("motion 1 detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(50);
}
takeLowTime = true;
}

if(digitalRead(pirPin) == LOW){
digitalWrite(valvePin, LOW);

if(takeLowTime){
lowIn = millis();
takeLowTime = false;
}
if(!lockLow && millis() - lowIn > pause){
lockLow = true;
Serial.print("motion 1 ended at "); //output
Serial.print((millis() - pause)/1000);
Serial.println(" sec");
delay(50);
}
}
}

Common PIRs are intended to detect human-size targets and ignore rabbit-sized targets. You may have to get the sensor very close to the rabbits or adjust the sensitivity in some way.