Nikon Shutter release - Code mod help needed

Frenchy living in Egypt trying to do things! :laughing:
I just finished to build a new project, a photogrammetry turntable controleed by Arduino, this is a link to the project
Now, I am not satisfied with both option for the camera trigger system (a servo pushong a button...or a HC06 based bluetooth trigger...)
The camera I want to use is a Nikon D300, and I plan to use the Nikon shutter release plug directly connected to the Uno to take the pictures.
Here is how it works on the D300 Side:
I use only 3 pins out of the 10 available.
Pin 6 = GND, pin 9 =AF, pin 4 = Shutter
When pin 6 and pin 9, Camera focus
Whe pin 6 + pin 9 + pin 4 are wired together, Shutter is released.

Being a bit of a noob when it comes to coding, I am seeking for help to modify the here attached code to use the release shutter cord instead of the HC06.
I understand that I have to attach the Nikon cable to the UNO, I have some GND pins available, and pins D3 and D13 are available...now when it comes to the code...I need your help!

Thanks for your time!

Here is the original code using the HC05/06 BT module:

Code_contribution_from_Ryan_Hashiro.ino (22.9 KB)

not an answer to your needs but you can look at my small tutorial (in French - should be ok for you) on how to trigger a canon camera and possibly a flash

Contrôler son Appareil photo (Canon) et un Flash Cobra avec Arduino

that might give you some ideas, as it's basically the same idea it seems

Thanks for your reply!

I understand the concept and the code for focus/trigger:

void photo(unsigned long t = 0)
{
  digitalWrite(focusPin, HIGH);
  digitalWrite(shutterPin, HIGH);
  delay(t > shutterMinTriggerDelay ? t : shutterMinTriggerDelay);
  digitalWrite(shutterPin, LOW);
  digitalWrite(focusPin, LOW);
}

But as a noob, I don't have a clue where to modify the HC05 BT part in the original code and replace it by this...

PS: I am french, but I write in this post in English, so everybody can follow up!

From my understanding, in the original code, i should replace this:

void takePhoto()
{
  // Serial.println("Taking a pic");
  _txData.command = CAMERAPRO_CAMERA_CONTROL; // The command.
  strcpy(_txData.value, "capture");           // The value for triggering image capture as described in the API manual.
  _etOut.sendData();
  myBluetooth.flush();
  // Serial.println("Took a photo");
  // bip();
  delay(500); // to allow for lag
}

void pullFocus()
{
  // Serial.println("Focussing");
  _txData.command = CAMERAPRO_CAMERA_CONTROL; // The command.
  strcpy(_txData.value, "focus");             // The value for triggering image capture as described in the API manual.
  _etOut.sendData();
  myBluetooth.flush();
  // Serial.println("Done focussing");
  delay(500); // to allow for lag
}

void startVideo()
{
  // Serial.println("Starting VT");
  _txData.command = CAMERAPRO_CAMERA_MODE; // The command.
  strcpy(_txData.value, "video");          // The value for triggering image capture as described in the API manual.
  _etOut.sendData();
  myBluetooth.flush();
  //// Serial.println("Done");
  // bip();
  delay(500); // to allow for lag
}

void stopVideo()
{
  // Serial.println("Stopping VT");
  _txData.command = CAMERAPRO_CAMERA_MODE; // The command.
  strcpy(_txData.value, "normal");         // The value for triggering image capture as described in the API manual.
  _etOut.sendData();
  myBluetooth.flush();
  // Serial.println("Done");
  // bip();
  delay(500); // to allow for lag
}

by this:

void pullFocus
{
  digitalWrite(focusPin, HIGH);
delay(500); // to allow for lag
  digitalWrite(focusPin, LOW);
delay(500); // to allow for lag
}

void takePhoto
{
  digitalWrite(focusPin, HIGH);
  digitalWrite(shutterPin, HIGH);
delay(500); // to allow for lag
  digitalWrite(shutterPin, LOW);
  digitalWrite(focusPin, LOW);
delay(500); // to allow for lag
}

I tried, but not photos, nor focus......

Show your circuit

Have you tested the operation of the two lines without connecting them to the Arduino? If you connect the focus line to the camera's ground line, does the camera autofocus? And if you then also connect the shutter line to ground, does it take a picture? If not, then perhaps you have selected the wrong lines.

Also, it is safer to do this with transistors because the camera and Arduino have different power supply voltages. Do you have two NPN transistors, or perhaps two N-channel mosfets?

i tried with the wires only, without arduino, it works fine!

I am using opto couplers, will post my wiring in a minute!

you need resistors with your optocouplers otherwise you risk drawing too much current from your poor arduino's pins

Like this 220 Ohms should be enough?

Yes, enough. But your diagram leaves a huge margin of uncertainty because it's a Fritzing mashup not a real schematic. So we can't tell if you have designed it with the right component connections. Your opto's have no input/output labels...

here is the schematics, and the opto module i have in hands!


I have:
D13 >> IN1
D3 >> IN2
GND >> IN1 GND
GND >> IN2 GND

and:
OUT1 >> Camera focus pin (Nikon #9)
OUT2 >> Camera focus pin (Nikon #4)
OUT1 GND and OUT2 GND >> Camera GND (Nikon pin #6)

U3 output connects ground to ground. That doesn't seem right.

You didn't mention the module before. You don't need or want 220 ohm resistors with that.

What do the yellow jumpers do?

Your schematic also has unlabeled connections. Please fix that.

I suggest posting images of your actual wiring.

on the camera side, when i just stick some wires in:
pin #9 + pin #9 = camera is focusing
pin #4 + pin #6 + pin #9 = Shutter releases

To what hardware does your "pin #x" terminology refer?

Great. Please make a real diagram from that.
Are the LEDs on the module coming on when they should?

to the shutter release connector on the Nikon D300 side, it is a 10 pin nikon cable

no leds....
And I am not very good at making Diagrams, just a basic Fritzing user...

If the LEDs aren't coming on, the connections to the Arduino from the opto module are incorrect.

Or, it's the code. Please post the entire current sketch.

Here is the test Sketch I using the moment for testing....

// Simple test Sketch which should take one photo every 5 seconds after focusing....



void setup() {
  pinMode(3, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  
void takePhoto
{
  digitalWrite(D3, HIGH);
  digitalWrite(D13, HIGH);
delay(500); // to allow for lag
  digitalWrite(D3, LOW);
  digitalWrite(D13, LOW);
delay(5000);
}
          }

Post images of your wiring. The LEDs should be coming on.

Oh, wait. Will that even compile? You declared a function inside a function.

Right, I test compiled it and it failed to compile. So what is going on over there?