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

Ads by Google

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.


  • 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.


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.

Ads by Google


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


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);

void loop() {
	val = analogRead(piezo);    
		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();
		digitalWrite(cameraPin, LOW);


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.


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.


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.


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


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


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


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.

Join live MakeUseOf Groups on Grouvi App Join live Groups on Grouvi
Raspberry Pi Projects
Raspberry Pi Projects
571 Members
DIY Tech Projects
DIY Tech Projects
378 Members
Smartphone Photography
Smartphone Photography
361 Members
Arduino Projects
Arduino Projects
346 Members
300 Members
Affiliate Disclamer

This article may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.
New comment

Please login to avoid entering captcha

Log In