Here’s sample code used for a DIY wedding photobooth we built last summer. The physical setup involved an external touchscreen computer, Arduino board controlling 2 relays, and USB webcam. When the user clicks on the orange button (via touchscreen), an event structure is triggered which takes a sequence of 4 images (at 500 ms delay between), stiches them together into a single image, and finishes it off by playing a plays a .wav file and flashing an external light. The computer and touchscreen were mounted into an MDF “photobooth” cabinet.
The Arduino relay turned “on” a desk-type lamp while the pictures were being taken, then turned it “off” at the end of the sequence. A serial connection between the computer and Ardunio sent one of four different text strings indicating which relay to close/open. The Arduino board itself was setup to continuously monitor for these strings, and switch a digital output as necessary.
To test/run it, you’ll need to modify the loop which reads the webcam to suit your particular setup. We used a Sony USB webcam and had the vision development module installed. It was a quick project, so while there are probably much more efficient ways to code it.