Wednesday, July 10, 2013

Camera shutter control for Arduino

I'm building a remote shutter release for my Nikon DSLR. I'm using Arduino to light up an Infra-Red LED.  There are many libraries that provide the correct LED pulse for Nikon cameras. Unfortunately, they don't often work, leading to time-consuming debugging. So here is the current state of affairs when it comes to Nikon IR shutter release through Arduino.

The library that works

The Arduino Multi Camera IR control by Sebastian Setz. I have version 1-91 of the library. My current environment is Arduino 1.0 that is pre-packaged for Ubuntu (I obtained it through apt-get install). I'm using this on an x86 laptop. Currently I'm using an Arduino Mega for this, though I'll switch to an Atmega328 for the real project. The IR LED is a 940nm component I bought many years ago.

I mention this in painful detail to illustrate everything that was under suspicion when the project didn't work out. The sample code involved is trivial.  But when things don't work out, debugging can get quite involved as you check every thing methodically.

The library above is the Swiss-Army knife of shutter control. Not only does it work with Nikon, but it also works with other, lesser known brands. Minolta, Sony, Pentax, Olympus, even obscure brands like Canon.

The libraries that don't work

Von Roth's Nikon library:  I had used this in the past with one of my Arduino boards and it had worked on the first try. So this was the first library I used. I was disappointed when it didn't trigger my shutter. I thought the culprit was the IR LED, since it had sat in the bottom of a parts-box for a few years, and looked rebellious at this mistreatment.

Lady Ada's intervalometer code: Given the considerable reputation of Lady Ada, I was certain that this code would work. But I couldn't get it to work, again, leading to more unjustified suspicion heaped on the IR LED.

The debugging was fun, though only in retrospect. To test whether the LED was working, I pulled out my baby monitor and verified that the LED was indeed emitting some Infra-red. A few Arduino boards were swapped, I switched from x86_64 to x86, I switched to the old installations of Arduino.

Hope this saves you some effort.

Credits for the image and the library: Sebastian Setz