Parallax PIR.....code addition to existing PDE

Hello all....
I currently have an Arduino lightning trigger, that I want to adapt to a motion trigger for photographing hummingbirds.

Here's the current PDE that I'm using....

#define PIN_STATUS 13
#define PIN_IR_LED 12
#define FREQ 38400  // IR frequence
#define LIGHTNING_TRIGGER_ANALOG_PIN 0
#define TRIGGER_THRESHHOLD 50
 
//shutter sequence (on,off,on,off ... in microsecond)
unsigned long sequence[] = {2000,27830,390,1580,410,3580,400,63200,2000,27830,390,1580,410,3580,400,0};
int seq_l;
int lightningVal;

//oscd is a delay in microsecond used at each oscillation.
int oscd;
 
void oscillate(int pin, unsigned long n, int shine){
    int ir_status=0;
    while(n>0){
        n--;
        delayMicroseconds(oscd);
        ir_status  =  !ir_status; 
        digitalWrite(pin,  ir_status && shine);  
    }
}
 
void snap(){
    int i;
    digitalWrite(PIN_STATUS,  1);  
    for(i=0;i<seq_l;i++){
        oscillate(PIN_IR_LED, sequence[i], i%2==0);
    }
    digitalWrite(PIN_STATUS,  0);
}
 
void setup() {
    lightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);
        int min=1, max=100, i;
    int last_oscd=0;
    unsigned long before, intervalle;
    oscd=max;
 
    seq_l = sizeof(sequence)/sizeof(unsigned long);
 
    pinMode(PIN_STATUS, OUTPUT);
    pinMode(PIN_IR_LED, OUTPUT);
    Serial.begin(9600);
 
    //this "while" will process the best "oscd"
    Serial.println("Ready");
    while(last_oscd!=oscd){
        last_oscd=oscd;
        oscd=(min+max)>>1;
 
        before=millis();
        oscillate(PIN_STATUS, FREQ, 1);
        intervalle=millis()-before;
 
        if(intervalle >= 1000) max=oscd;
        else min=oscd;
 
        Serial.print(intervalle);
        Serial.print(" : ");
        Serial.print(min);
        Serial.print("<->");
        Serial.println(max);
    }
 
    Serial.print("oscd: ");
    Serial.println(oscd);
 
    //rewrite the sequence array, we replace all values in microsecond by the number of oscillation
    for(i=0;i<seq_l;i++){
        Serial.print(sequence[i]);
        Serial.print("->");
        sequence[i] = (sequence[i] * FREQ) / (intervalle * 1000);
        Serial.println(sequence[i]);
    }
}
 
 
void loop() {    
    {
  int cmd;
  int newLightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);
  Serial.println(lightningVal, DEC);
    
  if (abs(newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)
  {
    snap();
    Serial.println("Shutter triggered");
    //delay(200);
  }

  lightningVal = newLightningVal;
}

}

Understanding that I need to remove the code that deals with the phototransistor, where would I put the code for the PIR sensor? When motion is detected, I still want it to perform the action of writing to the IR led (which is what I couple up to the camera IR sensor).

Basically, I just want to use my current setup, but instead of detector a change in light, and triggering the camera, I want to detect motion and trigger the camera.

Can anyone help me out with this?

thanks....

Jim

Do you want to trigger on both hummingbirds and lightning?

Is the PIR sensitive enough to detect the heat of a hummingbird?

(please use the code "#" button when posting code)

AWOL,

I want to trigger on the bird's motion. I'm going to redesign the lightning detector that I have now, and will replace the phototransistor with the PIR sensor.

It was my understanding that the PIR was very sensitive indeed....maybe someone here can answer the question....I plan to have the camera set up about 3 to 4 feet away from the feeders, so will the PIR sensor detect the motion of a hummingbird from that distance? Anyone?

Thanks....

P.S. Sorry about not using the code button.....rookie mistake....

Great... Now I am thinking about warming a small potato in the microwave and throwing it at my Parallax and my Panasonic PIRs to see if it would trigger... How am I going to explain potato all over the wall and floor to my wife...

The PIR uses lenses to focus heat on the sensor - and most of them have some window and sensing areas where they work great, and other areas that don't work at all. (They are not really "motion" sensors but rather heat-level-change detectors...)

I checked the spec sheet for my panasonic, and it even warns.. "Cases where it is difficult to detect the heat source..."  "...When the heat source inside the detection range hardly moves or when it moves at high speed" and then "when outside, where infra-red light can hit the sensor."

Sounds like a bird, outside to me. :wink:

You may want to try a couple of sharp IR range detectors mounted in front of the feeder. When the range drops rapidly, a birdy is there. They have some good narrow-beam detectors that you could cross-direct. (RobotShop | Robot Store | Robots | Robot Parts | Robot Kits | Robot Toys) They work well in IR flooded areas, but still can't have sun directly on them.

Perhaps mount it above the feeder pointing at the ground?

What about a beak-in-feeder detector? Perhaps a micro switch would be better? ...Or some capacitance sensor on the front feeding part of the feeder?

Well, crap....that's not what I wanted hear !! Back to the drawing board, but hey, at 10 bucks each for the PIR, just might give it a go anyway !

Thanks for the info...

Jim