First Arduino Project – Distance Control Shutter Release

I picked up an Arduino last weekend after my friend Eric introduced me to it (this is the same friend who got me hooked on Mac). I couldn’t wait to order it on Amazon, and just decided to spend a little more on it at Radio Shack to have it in hand. Exactly one week later I have burnt two fingers with a soldering iron, broken open one alarm clock for parts, clipped the ends of about 3 sets of headphones and dumped money on all kinds of wires, sensors, LEDs, transistors, diodes and resistors… Oh, and I stole some of my daughters’ Legos.

For my first “real” project I created a shutter release using an Arduino Uno, Arduino Ultrasonic Distance Module, Canon T2i, Legos and an RCA cable.

IMG_2612It was relatively simple to figure out that the Canon shutter release operates by detecting a change in voltage (off/on) in the input cable, but this isn’t really the proper way to go about it (and in fact, sending voltage from an external source may damage the camera). The proper way to close the shutter (or focus) is simply by completing the circuit. I used am optocoupler to do this. My shutter output sends 5vv to the optocoupler, which is turn completes the circuit to the shutter input on the other side.

Using a left/right 2 channel 2.5mm adapter, you can focus and operate the shutter in the same way. I only had a single channel adapter at home, so I put the lens of my camera in M focus mode and only operated the shutter. For grins, I added an LED to turn on when a picture is snapped. To keep it all contained I snagged some of my daugthers’ Legos.

This is a fun starter project because its something that is actually usable (e.g., See the Rupert Christmas Tree video). The code I wrote is pretty straightforward (and not to be taken as an example of graceful code by any means). This is more demo code than anything. It snaps a picture if something is detected within 12 cm of the distance sensor.

I think I may actually set this up in some kind of enclosure outside this summer and see what kind of critters I might captures pics of in my back yard. If I get lucky, I’ll get a picture of the elusive Bigfoot!

#define shutter 2
#define trigPin 12
#define echoPin 13
#define light 7

// the setup routine runs once when you press reset:
void setup() {                
  pinMode(shutter, OUTPUT);  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

int getDistance()
  float duration, distance;
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  Serial.println((duration/2) / 29.1);
  digitalWrite(shutter, LOW);
  return (duration/2) / 29.1;


// the loop routine runs over and over again forever:
void loop() {
  float dist = getDistance();

  Serial.print("distance: ");

  // The next write releases the shutter
  if (dist < 12)
    // Turn the light on when a pic is snapped
    digitalWrite(light, HIGH);
    digitalWrite(shutter, HIGH);
    digitalWrite(shutter, LOW);

  digitalWrite(light, LOW);

…For my next trick, I’d like to add a display and perhaps some simple inputs to program the sensor range.


3 thoughts on “First Arduino Project – Distance Control Shutter Release

  1. Super cool! Arduino is something I’ve been looking to mess around with for a long time. Any good suggestions on where to get started?

    1. Look at SparkFun or Adafruit–Lots of good things for sale and they don’t leave you hanging with the item details–There are lots of great comments on each item about what over things you’ll need. An Arduino Uno is the best place to start.

Comments are closed.