Wednesday 8 February 2012

Arduino - camera time lapse controller

I went out and online to look for a remote control to for my Canon Powershot G12. The most basic which featured one button to just take pictures cost about 10 pounds. However I wanted something that will continuously take pictures for me so that I can create a time lapse video. A remote unit to do that would cost at least 70 pounds. At first I thought that would be fine with all the additional functions that I can do with it, but I still decided to have a look at what it would really do.

What really ticked me off was when I found this site that showed the wiring needed for the 2.5mm jack. Was that all?!! I'm paying money to connect its own ground to its shutter and focus?!? If go to the site, you'll see what I mean.

Seeing that I have a load of electronics lying around, I decided to make my own camera controller.

To test the theory of the site above to see if the wiring is really that simple, I connected wires to a 3 pole 2.5mm jack and just plugged it in to my camera and connected the wires to see what would really happen. Yes, it worked. I controlled the autofocus and the shutter control. So the next thing to do was to connect it up to a tactile push button and control it properly. That worked even better. So I had a fully functioning remote control that will allow me to not touch my camera to take a picture in a fixed position.

Here is a picture of the final product. I've gone and modified it to the point of using optocouplers as a relay switch and the push buttons you see there are to control the start and stop taking pictures.

The timing of the shots taken are all controlled in the programming of the Arduino. I'm considering adding some sort of display to allow changing the timings to be done without a computer present. Also, a cheaper version of the Arduino so that I can take it out and use it for something else.

Click here to see a simple experiment of the outcome of creating this project. It's watching ice melt so it's going to be a boring watch BUT what you can't see is that it's 2 and a half hours shrunk into just 20 seconds.  I set it up to take pictures every 20 seconds. In the video rendering, I made it so that it was 24 frames a second. This way, it would be more compatible with any file format I save the video.

I've got to find something more worthwhile taking a time-lapse photography for!

update: I've been asked to provide my coding for my Arduino to help people out. It's actually a combination of 2 other people's coding. One to get the latch working on a push button and the second is the actual taking pictures with a simple relay/optocoupler. I'm still streamlining it and improving it to make it work better.

so here it is:



    int INTERVAL_TM = 7000;     // 7 seconds shot interval
    int EXPOSURE_TM = 1000;     // keep fixed at 500 - 1000
    int CAMERA_PIN = 13;        // my pin that will trigger the camera
    int STARTSTOP_PIN = 3;      // a pushbutton to allow start of time lapse

    int val;                    //value of button press
    int buttonState;            //check variable for change of button press
    int on_off = 0;             //state of sequence (turned on, turned off)

void setup(){

    pinMode(CAMERA_PIN, OUTPUT);   //set CAMER_PIN as an output
    pinMode(STARTSTOP_PIN, INPUT); //set STARTSTOP_PIN as an input
   
    buttonState = digitalRead(STARTSTOP_PIN);    //read value of the button

}

void loop(){

    val = digitalRead(STARTSTOP_PIN);  // read button value and store it in val

    if (val != buttonState) {          // if the button state has changed…
      if (val == LOW) {                // check if the button is pressed…
        if (on_off == 0) {             // if the sequence is currently off…
          on_off = 1;                  // turn the sequence on
          delay(EXPOSURE_TM);          // wait the initial period
        } else {
      on_off = 0;                      // turn the sequence off
    }
    }
    }

    buttonState = val;                 //switch the button state

    if (on_off == 1) {                 //take some pictures time
 
      digitalWrite(CAMERA_PIN, HIGH);  //pressing camera button
      delay(EXPOSURE_TM);              //doesn't need to be long at all
      digitalWrite(CAMERA_PIN, LOW);   //let go of camera button
      delay(INTERVAL_TM);              //interval between shots
    }
   
}