Controlling a camera with an Arduino

Arduino camera controller.

This project allows external events to trigger a DSLR, causing it to take a picture. The event could be an interval timer, an object intering the field of view of a PIR detector, an IR interrupter or just a pushbutton. It is made by sacrificing a remote shutter release button to get the cable that fits the camera. The cable is connected to an Arduino for control.

I started with a cable costing less than $3.00, picked up on ebay. The pushbutton end was opened to reveal the circuitry.

Remote shutter release opened.

They spent more than the $3 I paid for this thing on glue to glue it together. I had to use a razor saw to start an opening on the seam, then use a screwdriver and considerable force to break it open. Start from the end opposite the cable, so you don't accidentally rip the wires off before you get a chance to see where they go. Inside mine was a tiny circuit board, held in with tiny screws. Removing the screws allows the circuit board to come out, as seen below.

Remote shutter release circuit board.

The camera has some odd voltages on the cable. With respect to ground, the photo wire is 0V and the focus wire is -2.7V. Pressing the button halfway results in +2.7V on photo and 0V on focus. Pressing it all the way causes both photo and focus to go to 0V. It it looks like we're going to need to isolate the Arduino from the camera. The obvious choices are relays or opto-isolators. Opto-isolators are faster, so we'll go with those, but regardless of how fast we go, the picture taking process is not immediate. There is a delay for the mirror to retract and the shutter to operate.

We need two opto-isolators to do the focus and photo functions, because the camera won't take a picture unless the focus connection is made first.

Arduino shutter release schematic.
Camera Control Schematic

The circuit is simple - two 4N35 opto-isolators and two resistors. Just three wires to the Arduino and three to the camera. I built it on a prototype board first to make sure it worked, then built it on a prototype shield.

Arduino camera controller self portrait.
Camera Control (self portrait)

The finished control took a picture of itself. Upon reset it waited 2 seconds, hit focus, waited three more seconds, hit photo, waited one second and turned everything off. That's all there is to taking a picture: Start the focus, give it time to complete, then start the photo. You may need to push the shutter button half way the very first time you shoot to allow it to find focus if it is too far out.


#define FOCUS 3
#define PHOTO 2

void setup() {

  pinMode(FOCUS, OUTPUT);
  pinMode(PHOTO, OUTPUT);
}

void loop() {

  delay(2000);
  digitalWrite(FOCUS, 1);
  delay(3000);
  digitalWrite(PHOTO, 1);
  delay(1000);
  
  digitalWrite(PHOTO, 0);
  digitalWrite(FOCUS, 0);
  while (1);
}
			

So with a program like that, you don't need a camera controller because you can just hit the button on the camera to take a picture. So how do we make it more interesting..?

We can use a PIR detector to take a picture when someone comes close enough. Just connect the PIR to pin 4, and VCC and GND to those pins on the Arduino, and use the following code. It assumes the PIR output goes low when it is triggered. If you have one that goes high when triggered, take out the exclamation point from the line that reads the PIR detector.


#define PHOTO 2
#define FOCUS 3
#define PIR   4

void setup() {

  pinMode(FOCUS, OUTPUT);
  pinMode(PHOTO, OUTPUT);
}

void takePicture() {

  digitalWrite(FOCUS, 1);
  delay(3000);
  digitalWrite(PHOTO, 1);
  delay(1000);
  digitalWrite(PHOTO, 0);
  digitalWrite(FOCUS, 0);
  
}
void loop() {

  if (!digitalRead(PIR)) {

    // Someone tripped the PIR - take picture.
    takePicture();

    // Wait 60 seconds before taking another picture.
    delay(60000);
  }
}
			

Another use for a camera controller is as an intervalometer, which takes pictures at evenly spaced intervals. The following code will take one picture every minute until 25 pictures have been taken.


#define PICTURES 25
#define FOCUS 3
#define PHOTO 2

int pictures = 0;

void setup() {

  pinMode(FOCUS, OUTPUT);
  pinMode(PHOTO, OUTPUT);
}

void takePicture() {

  digitalWrite(FOCUS, 1);
  delay(3000);
  digitalWrite(PHOTO, 1);
  delay(1000);
  digitalWrite(PHOTO, 0);
  digitalWrite(FOCUS, 0);
  
}
void loop() {

  // It takes 4 seconds to take one picture.
  takePicture();

  // Delay 1 minute minus 4 seconds.
  delay(60000 - 4000);

  // Count the picture but stop at PICTURES.
  if (++pictures > PICTURES) {

    // Loop forever
    while(1);
  }
}
 
Arduino Board Logo

 

Arduino-Board is the go-to source for information on many available Arduino and Arduino-like boards, tutorials and projects.

Help and Support

Arduino-Board

Stay updated

Sign up if you would like to receive our once monthly newsletter.