How To Use An Arduino To Shoot Beautiful High-Speed Photography

Smashing wine glasses and popping balloons is obviously fun in and of itself – that’s just how I roll. But combined with a DSLR camera and an Arduino, it can also make for some interesting photographs. That’s exactly what we’ll be doing today.

Project Basics

There are two parts to this project really – the first is a sound trigger. Using a piezo buzzer as a microphone and an Arduino, we can easily detect loud noises and define an action. The second part is the camera setup. Since triggering the camera directly would be too slow, we’ll be leaving the camera shutter open in a dark room and using an external flash to provide just enough light to complete the shot.

If you’re completely new to photography, check out my top 5 photography tips for absolute beginners. If this project is a bit complicated for you, why not have a go at tilt-shifting to give your photos a model diorama effect instead.

Equipment

  • DSLR camera with tripod
  • External flash with manual trigger
  • Arduino
  • Piezo buzzer and 1M Ohm resistor
  • 4N35 or similar opto-coupler / opto-isolator and 220 Ohm resistor

Wiring Diagram

The piezo buzzer should be hooked up black wire to GND and red to A0; place the 1M resistor between the two pins. The resistor is used to provide a current drain for the voltage produced by the piezo, protecting the analog input.

arduino circuit   How To Use An Arduino To Shoot Beautiful High Speed Photography

We’re using an opto-isolator to protect the Arduino from any voltage the external flash might have. An opto-isolator is an LED and light sensitive switch in a tiny package; turn the LED on one side and the switch on the other will be activated. On the 4N35 (other models may vary), you should see a very small circle in one corner – this pin 1. Connect pin 1 via the 220 ohm resistor to pin 12, and then pin 2 to GND. The device being triggered goes onto the two pins in the opposite corner (5/6). The end of these trigger leads can either go to an actual flash trigger cable, or just jury-rig them straight into the socket – you might need some Blu-Tack to make them stay in place.

flash trigger   How To Use An Arduino To Shoot Beautiful High Speed Photography

Here’s the completed circuit hooked up to the flash.

completed circuit   How To Use An Arduino To Shoot Beautiful High Speed Photography

Arduino Code

The code for this project is relatively simple. In the file below, I’ve left Serial console output in, though you may want to remove that when you’re sure things are working – just comment out the Serial.begin and Serial.println lines when you’re ready. Run the code and watch the console output as you clap your hands – you should be getting an output from the piezo buzzer. The numbers you have here can be used to determine the threshold at which the flash fires, but my piezo wasn’t at all that sensitive so I left it at 1.

In the main loop, we’re checking if the piezo reading is above the threshold and if it’s been more than a second since the last time we triggered the flash. This avoids triggering the flash more than once. On some flashes, this might not be necessary, but since mine was capable of sustained bursts it was simply firing multiple times without that check.

Also, note the delay value before triggering the flash – you’ll want to either play around with this or remove it completely, depending on what it is that you’re photographing. Without the delay, the photo of a smashed glass was taken immediately upon impact, with no shattering effect. 50ms was a little too slow, so 25ms should be ideal to see actual shattering.

int ledPin = 13;
int cameraPin = 12;
int piezo = 0;              
unsigned long lastMillis = 0;
byte val = 0;
int threshold= 1;

void setup() {
	pinMode(ledPin, OUTPUT);
	pinMode(cameraPin, OUTPUT);
	Serial.begin(9600); 
}

void loop() {
	val = analogRead(piezo);    
	if(val>0){
		Serial.println(val); //used to debug
	}
	if (val >= threshold && (millis()-lastMillis > 1000)) {
		delay(25); // change as needed, or remove entirely
		digitalWrite(ledPin, HIGH);
		digitalWrite(cameraPin, HIGH);
		lastMillis = millis();
	}
	else{
		digitalWrite(ledPin,LOW);
		digitalWrite(cameraPin, LOW);
	}
} 

Shooting

First off, you’ll need a dark room to do this – the closer you can get it to pitch black, the better. If you find your shots are too blurry, it can be due to too much ambient light. The only light you want for this shot is at the moment the flash is triggered, so put your DSLR into manual mode and put the exposure time up to 4 seconds or more. Set your aperture to around F8 to F16; I needed an ISO of 1600 to capture these shots, but you should tweak both these values to find something that works for you before going ahead.

You’ll also need the camera set on manual focus, and disable any stabilisation if you have it. Play around with your flash timings – I used 1/128 power – any higher than 1/32 and you’ll find the flash fires for too long, resulting again in blurry shots. I’m certainly no photography expert though, so it’s really just about playing around to find settings that work for you.

An easy way to test your setup is to kill the lights, click the shutter, then clap – the shot should come out well lit and not blurry.

Satisfied with my tests, I went ahead and tried popping a balloon.

hs balloon2   How To Use An Arduino To Shoot Beautiful High Speed Photography

The code could do with being optimised a little – even with no programmed delay, it seems like the shot was just 5-10 ms too slow for capturing the moment. Still, this one came out nicely and shows the marbled balloon colours and a bemused dog.

hs balloon 1   How To Use An Arduino To Shoot Beautiful High Speed Photography

This was my initial attempt at shattering things – with no delay, the photo taken directly at the moment of impact and isn’t particularly exciting.

hs no delay glass   How To Use An Arduino To Shoot Beautiful High Speed Photography

A 10 ms delay was just slightly too soon for this mug.

hs 10ms cup   How To Use An Arduino To Shoot Beautiful High Speed Photography

I tried again with the other half of the cup and a 50 ms delay – just slightly too late I feel:

hs 50ms cup   How To Use An Arduino To Shoot Beautiful High Speed Photography

I gave 50ms another chance with this glass – make sure you’re shattering things into a box to make clean up easier!

hs 50ms glass   How To Use An Arduino To Shoot Beautiful High Speed Photography

The great thing about DSLRs is that you can take a million shots until you get it right, though your glassware is going to get expensive. I’ll be honest, I took the entire day tweaking and hundreds of practice shots of me clapping to find the right settings, so don’t give up if it doesn’t work right first time.

Once you’re bored of balloons and glasses, try experimenting with different kinds of triggers: maybe a ping sensor placed on the ground that captures falling object, or a laser light and photodiode resting just above water that triggers when the light beam is broken. Take any good shots? Let us know in the comments how you got on or any problems you encountered.

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

5 Comments -

0 votes

Christian C

I bet your parties are expensive ;)

Great read. Some of the end results were great, but I wouldn’t be surprised to learn you’ve got as many spare photos from this as broken glasses…

0 votes

Gde S

Cool hack! Thanks for sharing it.
I foresee a Kickstarter fund to purchase more glassware.

0 votes

a. maldonado

I’ m going to try this.

0 votes

Gren

I did a bit of searching and looked at various Arduino photographic projects and followed a few of them. I used an LM358 op amp with a mic. Used the output to feed into the Arduino which then operates the flash. I found it was so sensitive that the noise of turning the main light off would set off the trigger.. I sent the shutter for about 4 seconds but opened it with a remote. I got my dear wife to pop the balloon which she heard me open the shutter.. plenty of leeway during the 4 seconds. Pitch black room .. bang, flash and then close the shutter. I have a laser on order to trigger using other methods but at least this one worked.

0 votes

Ru

Thx for the docu :)
Cool thing :D