Hello all,
I'm new to this forum and this will be my first post.
So please be gentle if I make beginner mistakes.
Below you can find a description of what I want to achieve.
I'm sitting in a hide to photograph owls at night. Most of time I'm sitting there for 3 hours.
Because I need my sleep I was thinking of turning my systemcamera's (CANON R6 MKI and/or CANON R7) into a wildtrap. The wildtrap will be installed at the moment I decide to go home and get my sleep.
So I bought a PIR sensor and hooked it up with and arduino nano every.
I can read the sensor, activate the focus and shutter and take pictures . So far so good .
But at the moment I add an external flash things are going wrong.
The flash is firing after the shutter is alread closed. (The flash is needed for future projects)
So what I want to achieve is that the flash triggers at the same time as the shutter is activated.
I alread had a look to the millis() function and the examples of doing actions at the same time , but I have difficulty's to understand it . Setting up state machines is not something that I do often.
A second thing that I nottice is, if I take multiple shots the first shot is never in focus although I'm waiting enough. The following shots seems to be in focus
My camera is set in AI servo mode / single shot with mechanical shutter and eye detection for humans to test.
I'was thinking of writing to the port directly so that the pins are set at the same time as described in the link below .
https://docs.arduino.cc/learn/programming/bit-math/
It is unclear to me to which port the pins of the nano every are belong to.
So any advice is welcome here .
Below is the code .
//code begin
const byte shutter = 12;
const byte focus = 11;
const byte flash = 10;
const byte sensor = 16;
const byte LED_ACTIVE_PIN = 15;
const byte LED_WAITING_PIN = 14;
int focusTime = 500; // delay to allow the camera to auto focus
int minTime = 2000; // minimum time before a sensor re-trigger can initiate a sequence
int shots = 1; // number of photos taken per trigger
int pause = 1000; // mili secs between camera taking shots
int Flash_duration = 100;
boolean PIR_triggerd =false;
int count= 0;
void setup() {
pinMode(shutter, OUTPUT); digitalWrite(shutter, LOW);
pinMode(focus, OUTPUT); digitalWrite(focus, LOW);
pinMode (flash,OUTPUT); digitalWrite(flash, LOW);
pinMode(sensor, INPUT);
pinMode(LED_ACTIVE_PIN, OUTPUT);
Serial.begin(115200);
digitalWrite(LED_ACTIVE_PIN, HIGH);
delay(minTime);
}
void loop()
{
if ((digitalRead(sensor) == HIGH) && !PIR_triggerd) //first trigger
{
PIR_triggerd=true;
Serial.println("PIR Triggerd");
digitalWrite(LED_ACTIVE_PIN, HIGH);
//delay(minTime);
for (int i = 0; i < shots; i++)
{
Serial.println(count);
count++;
//digitalWrite(LED_ACTIVE_PIN, HIGH);
digitalWrite(focus, HIGH);
delay(focusTime);
digitalWrite(focus, LOW);
digitalWrite(shutter, HIGH);
digitalWrite(flash, HIGH);
delay(Flash_duration); // give enough time to activate the flash
digitalWrite(flash, LOW);
digitalWrite(shutter, LOW);
delay(20);
delay(minTime);
digitalWrite(LED_ACTIVE_PIN, LOW);
if (count == shots)
{
Serial.println("waiting for pir to become idle !");
while(digitalRead(sensor)==HIGH) //now waiting for the PIR to become idle again.
{}
count = 0; //reset counter of how much shots are taken for the next loop
PIR_triggerd=false;
digitalWrite(focus, LOW);
digitalWrite(shutter, LOW);
digitalWrite(flash, LOW);
digitalWrite(LED_ACTIVE_PIN, LOW);
delay(minTime);
Serial.println(" PIR is idle");
}//end if
} // end for
}// end if loop
}// end loop











