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

James Bruce 09-11-2013

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 7 Key Photography Tips for Absolute Beginners These photography tips will help you take better photos, whether you're a beginner or have some practice already. Read More . 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 5 Ways to Tilt-Shift Your Photos for Model-tastic Mockups Read More 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.



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.

Related topics: Arduino, Photography.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. simon
    May 8, 2018 at 3:14 am

    Hi! Total noob here; just trying to figure out what you mean when you say "place the 1M resistor between the two pins" - does that mean plug the resistor into the same holes as the pins from the piezo? In the diagram it looks like they're plugged into the same holes, but I don't think they fit on my board. Hoping you can clarify. Thanks!

    • James Bruce
      May 8, 2018 at 12:58 pm

      Correct. The 1 million ohm resistor should be on your arduino board, between the GND and A0 pin. They don't literally have to go into the Arduino board though - just break the pins out to a breadboard slot if you need to , and connect everything there, as long as the same connections are made it'll work fine.

  2. Johanna
    December 11, 2016 at 9:39 pm


    I am using this project as one for school as well, is there any possible way you could find time to answer few of my questions?

    • James Bruce
      December 12, 2016 at 11:22 am

      You could just ask them, and if I can't answer, someone else might.

      • Johanna
        December 12, 2016 at 4:02 pm

        How are you connecting your camera with Arduino, so it would take photos at the same time as the flash is triggered? I have Canon 60D, but I haven't found a simple solution yet..

  3. Anonymous
    August 11, 2016 at 3:28 pm

    What did you use as a power source? I wanna build this as a term project.

  4. Guus Jamin
    June 4, 2016 at 9:42 am

    Hi to hook op the camera to the arduino...the diagram shows to wires "trigger to camera". I use the Canon 7D can I hook up with the cable RA-E3?

  5. Anonymous
    November 29, 2015 at 12:32 am

    I'm in panic mode trying to get this project figured out. I am in the process of completing a project for my electronic arts class using the arduino but I'm not quite sure if I have the necessary parts. Is there any possible way you can answer some questions, Bruce?

    • James Bruce
      November 29, 2015 at 9:06 am

      Post them here. But it's James, not Bruce. ;)

  6. Anonymous
    June 10, 2015 at 2:03 am

    Thanks for the great writeup.

    I have an older flash which, when I probe the trigger wires, reads about 65V / 80mA. I gather this is pretty high.

    I'm a bit new to all this, just testing a simple setup - Blink sketch triggering optocoupler triggering flash. Flash isn't going off (it seems the flash circuit is completing right away and stays like that).

    I can fire the flash by bridging its trigger circuit manually, and I have the 4N35 working with a test LED, so both pieces work on their own.

    So - because of my voltage, should I look at a different optocoupler, or something else like a relay? Reaction time isn't important to me for my application.

    • James Bruce
      June 10, 2015 at 7:39 am

      I'm afraid I haven't played with high voltages much, so that's beyond my electronics knowledge. This thread over on the Arduino forums mentions a few components that should work though (they were using 160v flash):

  7. Gren
    March 23, 2014 at 12:48 am

    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.

  8. Gde S
    November 10, 2013 at 8:31 am

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

  9. Christian C
    November 9, 2013 at 6:47 pm

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