Archive for Photography

Camera Trigger

Update: Check out my latest Camera Axe project for a much more robust device that handles this.

This article explains how to use a microcontroller like Arduino to trigger the shutter on a Canon DSLR camera that has an N3 connector. Canon cameras like the 10d through the 40d and their professional cameras all have this connector. Many other DSLR cameras have a very similar connector that you could adapt this article to, but they’ll require a little more research from you.

This project would work well with another project I wrote about here. It describes how to trigger a flash with sound or a laser trigger. You could easily adapt it so it triggers your camera instead of the flash. Note that in that article I discuss the downside of directly triggering your camera (namely the delay), but if a delay of a fractional part of second doesn’t matter then triggering your camera directly works great. Some cool applications would be having your camera take a picture every time you say a word, taking a picture every time someone rings your doorbell, or taking a picture when someone walks down the hallway.

The most difficult part of this tutorial is getting a cheap N3 connector. Canon decided to go with a proprietary plug and they charge ridiculous prices for any accessory that uses this plug. I think their cheapest device with the N3 plug is a basic remote trigger and they charge $50 for it. You could try to make your own plug. But my favorite solution was to type “canon n3 remote” into ebay and I found lots of simple remote triggers for under $10. I just got my plug from one of these devices.

With the plug in hand I started figuring out what the different wires did. Here is picture of the the plug and the color of wire attached to each pin in the plug. The white wire is ground. The green wire is +3V and when it’s grounded it causes the camera to focus (similar to pushing your shutter button half way down). The red wire is +4V and when it’s grounded it causes the camera to take a picture (depending on the mode the camera is in it might focus first). If you want to guarantee a quick picture you should pre-focus your camera and then set focus to manual.

Now that we know how the N3 plug works all we needed to do is wire a circuit that lets us switch the green (focus) or red wire (shutter) to ground. I actually find the focus wire to be pretty useless since I can have the camera focus before it takes a picture if I want, but there are some use cases where it would be nice so I’ve included it here for completeness. I figured a simple switching transistor like the 2N2222 would be be the perfect switch for this project and so that’s what I used. See my circuit diagram below.

This example code for Arduino is very simple. All it does is focus when you hit the “f” key and and take a picture when you press the space bar key. Here is a link to the code.

// Maurice Ribble
// 4-28-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code just tests my camera trigger.  It lets you
// focus the camera by pressing the 'f' key and take a
// picture by pressing the space bar.

#define FOCUS_PIN 6
#define SHUTTER_PIN 7

void setup()
{
  pinMode(FOCUS_PIN, OUTPUT);
  pinMode(SHUTTER_PIN, OUTPUT);
  digitalWrite(FOCUS_PIN, LOW);
  digitalWrite(SHUTTER_PIN, LOW);
  Serial.begin(9600); // open serial
  Serial.println("Press 'f' to focus and 'spacebar' to trigger shutter");
}

void loop()
{
  int cmd;

  while (Serial.available() > 0)
  {
    cmd = Serial.read();

    switch (cmd)
    {
    case 'f':
      {
        digitalWrite(FOCUS_PIN, HIGH);
        delay(800); // May want to adjust this depending on focus time
        digitalWrite(FOCUS_PIN, LOW);
        break;
      }
    case ' ':
      {
        digitalWrite(SHUTTER_PIN, HIGH);
        delay(2000); // May want to adjust this depending on shot type
        digitalWrite(SHUTTER_PIN, LOW);
        break;
      }
    default:
      {
        Serial.println("Press 'f' to focus and 'spacebar' to trigger shutter");
      }
    }
  }
}

Comments (20)

Triggering a Camera’s Flash with Sound and Light

Update: Check out my latest Camera Axe project for a much more robust device that handles this or my store where I sell the Camera Axe.

For those just wanting to see the pretty pictures, click here.

This article focuses on making the sensors used to trigger a camera’s flash using a microphone or a cheap laser pointer. Since I’ve already described how to do the actual firing of a camera’s flash here I won’t focus on that part of this project today.

There are a lot of places on the web that describe how to trigger a flash with an electrical circuit, but I feel that using a microcontroller like Arduino offers big benefits. For instance you can easily add new sensors, or even run multiple sensors at once. Since the triggering of the flash is done in software it’s easy to add delays, or make a more complicated triggering algorithm based on multiple sensors. Lastly while the microcontroller does add some cost, it’s not much because boards like Arduino can be bought for around $35 and some of this cost for the microcontroller is offset by simpler circuits.

Now let’s talk about why we’re triggering the flash. The main reason is to help capture those moments that require extremely accurate timing. Computers are many orders of magnitude faster at waiting around for something to happen and then triggering the flash when that something does happen. Humans can try to compensate for this by watching the event and then trying to plan when to trigger the flash. For example when photographing a balloon popping, you can tell your friend to pop the balloon on the count of three and then take the picture on three. This sort of works, but this electronic flash trigger works much more consistently and it’s always ready to take the picture of those less predictable events.

Most SLR and DSLR cameras let you attach a cable to trigger the camera directly. Why not interface that camera trigger directly and just attach the flash to the camera if it’s dark? This would let you use the camera’s built in flash (my method requires an external flash unit). The reason we can’t do this is because camera’s are too slow. I’ve done some measuring of the delay between when you tell a camera to take a picture and when it actually takes a picture and found on my camera it’s around 20 ms. To a person this delay isn’t noticeable, but to a popping balloon it’s way too long. So instead of of triggering the actual camera we must trigger the much more quickly responding flash.

When I’m using this flash trigger I work in a dim room and set my shutter speed to 10 seconds. Since it’s nearly dark in the room the camera’s picture is still black after these 10 seconds. However if I trigger the flash for 1/1000th of a second that short burst of high intensity light is enough to light up the scene. So even though my shutter speed is 10 seconds, I’m effectively only taking a picture while the flash is active because that’s where all the photograph’s light is coming from.

Laser Sensor

This first sensor uses a cheap laser pointer and a photo resister to detect the laser’s light. The software is setup to trigger the flash when the laser beam is broken. The software also turns off the laser so it doesn’t show up in your photograph. Think of it as an electronic trip wire. This is great for catching moving objects. Add a small delay between the detection and triggering of the flash and you can catch cool things like a light bulb that is is smashing into the ground.

Since I didn’t have an extra laser pointer sitting around I bought this cheap laser card module. It’s very low power so I can run it off a digital output on the Arduino board. Originally I powered the laser directly from Arduino’s +3 volt output, but I found that it was better to run it off a digital pin so that the laser could be turned on/off. Since this laser runs on 3 volts and Arduino outputs 5 volts I used a voltage divider in my circuit to get the needed voltage. To sense the laser I used another voltage divider circuit with a photoresistor. An analog input on the Arduino was used to detect the if the laser was hitting the photoresistor or not.

Here’s the circuit.

Sound Sensor

This sensor detects noise. It’s very useful for detecting things like a drop of water splashing, or anything that makes noise. There are lots of places on the web that discuss how to build your own microphone and amplifying circuits, but I liked the idea in this article about using a guitar amplifier. A karioki machine or any other device that has a microphone input and an output line should work. You can pick up a low quality amp and microphone pretty cheaply on ebay or in a retail store. Sometimes you can get them really cheap at a garage sale.

The signal you get from an amplifier is going to be an electrical AC wave representation of the sound going into the microphone. This often means something like a 5 volt 8 kHz wave. The only thing I did was to add a diode to protect the analog input I was using on my Arduino board from the negative portion of this wave. Here are some pictures from my oscilloscope of the wave being generated by the amp. The first one is the full wave of my voice (I was singing “Twinkle Twinkle Little Star”), and the second picture is what it looks like with a diode.

You can see that the bottom half of the waves are getting chopped off, but that should be fine. The Arduino is more the fast enough to detect the voltage spikes. You could even make more sophisticated software to only trigger on certain frequencies of sound, but for now my software just looks for any sound spike over a certain threshold voltage.

Here’s the circuit.

Flash Trigger

I’ve already discussed this part of the system in this article, but for completeness here’s the circuit.

Building a Box to Hold it All

After understanding how all of these circuits worked it was time to put them all together and build a box that would handle all my flash triggering needs. Here are some photos of what I created.

Software

Last, but not least here is the software I wrote to run it.

// Maurice Ribble
// 4-12-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code is designed to to tune (see PRINT_MESSAGE define) and
// to run a sound sensor and a laser sensor.  Both of these sensors
// Are used to trigger a flash.  It should be easy to add additional
// sensors if you want.

// These enable the different types of triggers
//#define ENABLE_LASER_TRIGGER
#define ENABLE_SOUND_TRIGGER

// The threshhold values for the different triggers.
// These may need to be changed depending on evironment and sensors being used.
// Using PRINT_MESSAGES can help determine the correct value for these.
#define LASER_THRESHHOLD 500
#define SOUND_THRESHHOLD 100

// This prints messages to the serial port.  This is good to enable while determining
// the threshholds for your trigger, but these communications are very slow and
// when using these sensors to actually take pictures this should be turned off.
//#define PRINT_MESSAGES

// The digital pins being used
#define CAMERA_FLASH_PIN 4
#define LASER_PIN 5

// The analog pins being used
#define LASER_TRIGGER_ANALOG_PIN 0
#define SOUND_TRIGGER_ANALOG_PIN 1

void setup()
{
  pinMode(CAMERA_FLASH_PIN, OUTPUT);
  digitalWrite(CAMERA_FLASH_PIN, LOW);
  pinMode(LASER_PIN, OUTPUT);
  digitalWrite(LASER_PIN, LOW);

#ifdef ENABLE_LASER_TRIGGER
  digitalWrite(LASER_PIN, HIGH);  // Turn on the Laser
#endif

#ifdef PRINT_MESSAGES
  Serial.begin(9600); // open serial
#endif
}

void loop()
{
  int soundVal;
  int laserVal;

  ////////////////////////////////////////////////////////////
  // SOUND TRIGGER
  ////////////////////////////////////////////////////////////
#ifdef ENABLE_SOUND_TRIGGER
  soundVal = analogRead(SOUND_TRIGGER_ANALOG_PIN);
  if (soundVal > SOUND_THRESHHOLD)
  {
     digitalWrite(CAMERA_FLASH_PIN, HIGH);
#ifdef PRINT_MESSAGES
     Serial.println("Flash Triggered!!!");
#endif
     delay(100);
     digitalWrite(CAMERA_FLASH_PIN, LOW);
   }
#ifdef PRINT_MESSAGES
  Serial.print("Sound: ");
  Serial.println(soundVal, DEC);
#endif
#endif // ENABLE_SOUND_TRIGGER

  ////////////////////////////////////////////////////////////
  // LASER TRIGGER
  ////////////////////////////////////////////////////////////
#ifdef ENABLE_LASER_TRIGGER
  laserVal = analogRead(LASER_TRIGGER_ANALOG_PIN);
  if (laserVal < LASER_THRESHHOLD)
  {
     digitalWrite(CAMERA_FLASH_PIN, HIGH);
     digitalWrite(LASER_PIN, LOW);  // Turn off laser during picture
#ifdef PRINT_MESSAGES
     Serial.println("Flash Triggered!!!");
#endif
     delay(100);
     digitalWrite(CAMERA_FLASH_PIN, LOW);
     digitalWrite(LASER_PIN, HIGH);  // Turn laser back on after picture
   }
#ifdef PRINT_MESSAGES
  Serial.print("Laser: ");
  Serial.println(laserVal, DEC);
#endif
#endif // ENABLE_LASER_TRIGGER
}

Comments (109)

Super Simple Camera Flash Trigger

In this project we will be making a trigger for a camera’s flash. This flash trigger will be controlled with a microcontroller like Arduino. Today, I’m just covering how to trigger a camera flash with a microcontroller. Most likely you will also want to attach a sensor to a different port on the microcontroller and use that sensor to activate this flash trigger.

Some people might claim that using a microcontroller is overkill for a project like this, but I don’t think so. There are several advantages to using a microcontroller over one of a circuit like this. First I think using a microcontroller is easier to implement. Second you can modify the code to use multiple sensors or add in any delays you want. It’s just a more robust system and it doesn’t cost that much more. You can get an Arduino microcontroller for around $35.

Here is an article I wrote describing different sensors you can use with this flash trigger circuit.

The first thing you need (besides a microcontroller which I assume you already have) is a female hotshoe to use with your flash. I bought this one for $20. It was cheap and it uses a standard 1/8 inch jack. This is much better than the flash sync cables that are notoriously unreliable, but any hotshoe should work so if you have one with a standard sync cable use it. All that needs to be done to trigger the flash when it’s in the hotshoe is to short the two wires or contacts. I used a optoisolator (here’s the datasheet)as a switch. Optoisolators have the added benefit of protecting my Arduino board from any voltage spikes that might occur on the flash.

The software for this project is very simple. I just send a high signal to the optoisolater for 1/10 of a second when the spacebar is pressed. This triggers the flash.

// Maurice Ribble
// 4-9-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code just lets you turn a digital out pin high for a short time.
// That's all that is needed to verify the flash circuit is working.
// Press the space bar to trigger the flash.

#define CAMERA_FLASH_PIN 4

void setup()
{
  pinMode(CAMERA_FLASH_PIN, OUTPUT);
  digitalWrite(CAMERA_FLASH_PIN, LOW);
  Serial.begin(9600); // open serial
  Serial.println("Press the spacebar to trigger the flash");
}

void loop()
{
  int cmd;

  while (Serial.available() > 0)
  {
    int cmd = Serial.read();

    switch (cmd)
    {
    case ' ':
      {
        digitalWrite(CAMERA_FLASH_PIN, HIGH);
        delay(100);
        digitalWrite(CAMERA_FLASH_PIN, LOW);
        break;
      }
    default:
      {
        Serial.println("Press the spacebar to trigger the flash");
      }
    }
  }
}

Comments (38)

« Previous Page « Previous Page Next entries »