Instructables

Step 2: Software and Trigger Button

IMG_1824.jpg
IMG_1825.JPG
IMG_1826.JPG
Screen Shot 2011-11-06 at 3.58.28 PM.png
A Brief Overview
As previously mentioned, this photobooth uses the OSX Photobooth application. The OSX Photobooth application was chosen because it was the most stable software i could find - and it comes with every MAC computer. Like most applications, users can trigger features and functions with mouse clicks and keyboard commands.

Triggering the Photobooth Application
With OSX Photobooth, pressing the Enter Key triggers the program to take a photo. I didn't want to expose my computer to people hammering on the keyboard (espeically if they had been drinking). This is why i decided to use an external button, connected to an arduino microcontroller, to trigger the photobooth application.

This is how it works:


The button is pressed - A Staples Easy button was modified to act as a regular button. It's really durable, so people can beat on it without breaking it.

An Arduino registers the button press - When it registers a button press, it sends a serial command to the computer. In this case, it sends the [enter] serial command.

AAC Keys listens to the serial port for serial commands - AAC keys is a free application which litens for serial commands and emulates mouse and keboard events. You can download it here. In this case, when AAC keys receives the [enter] serial command, it tells the computer (and the photobooth application) that someone has just pressed the enter key on the keyboard.

When the photobooth application registers the enter key being pressed, it takes a photo.

Wiring the circuit - If you do not know how to make a button circuit for an arduino, read this tutorial - http://www.arduino.cc/en/Tutorial/button

B
e sure to connect the button to pin 10 on your arduino. If you choose to wire your button to a different pin, be sure to change [int buttonPin = 10] in the arduino code to match the pin number you selected.


Writing the code - Here is the code i wrote to send an [enter] serial command to the AAC Keys. If you are not familiar with writing arduino code, use this tutorial here. It's pretty easy once you get the hang of it. http://arduino.cc/en/Guide/HomePage

const int buttonPin = 10; // the number of the pushbutton pin

int buttonState = 0; // variable for reading the pushbutton status

void setup() {

pinMode(buttonPin, INPUT);
Serial.begin(9600); // open the serial port at 9600 bps:
}

void loop(){

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
Serial.println();
}
else {
// nothing
}

}

Installing AAC keys - As previously mentioned, AAC keys is a free program. "That receives commands through your computer's serial port and translates them into keystrokes and mouse movements, giving you full control of your computer from another device such as an [arduino]". You can download the program here: http://www.oatsoft.org/Software/aac-keys

Using AAC Keys is quite simple. Make sure you have an arduino plugged in via usb, running the code seen above. Open AAC keys application and access the applications preferences. When the dialogue appears, check to see that you have selected the serial port associated with the connected arduino (generally it's selected by default, but it is good practice to check), and that it is running at 9600 bps.

If you've done this, AAC keys should be interpreting the button press from the arduino as an [enter] command on the keyboard. open a text editor and give it a shot. Type a few lines of text and press the button attached to your arduino instead of using the enter key. You can also open photobooth at this time and see that pressing the button triggers the program to take a picture.

 
Remove these adsRemove these ads by Signing Up
bix1 month ago

I wonder if this could be simplified slightly by using something like the Teensy:

https://www.pjrc.com/teensy/

It's an ATMeg32u4 USB emulator. That way, all you'd need to do would be program the Teensy to send the return key's ascii whenever the external button is pressed. I've had a little experience with the Teensy and it's perfectly suited for an applicaiton like this!

matthew38382 years ago
I am having the same issue as pmoore10. I am wondering if maybe I downloaded the wrong version of AAC Keys???? Everything else seems to work. Does anyone have suggestions?
pmoore102 years ago
Hi this really good project, I have just started using arduino to interface with programs and was looking at ur code, although it works in the serial monitor I can not seem to get it to work with photoboth. I have downloded AAC keys and have it running I was wandering do I need to use a bluetooth shield with my arduino uno to send the key stroke as the only serial device i can pick in the aac pref is the bluetooth-pda-sync. I hope this makes sense and you can help me out...
I am having the same issue as pmoore10. I am wondering if maybe I downloaded the wrong version of AAC Keys???? Everything else seems to work. Does anyone have suggestions?
Thanks for the share and Idea!
Since I don;t have arduino, I would rather hack an old USB keypad. They are pretty cheap.

Also there are a couple of cooling fans designed for notebooks and laptop in some computer stores.

you can replace the lights into colored ones for another special effects.

My only problem now is how to add a flash into it that sync with shooting...

I agree with jiivaneshvar on the keyboard hack. Arduino is kinda overkill if you have a single, simple button embedded in the case. There are lots of tutorials on keyboard hacking in the DIY arcade community, just search for "MAME cabinet keyboard hack", and I'm sure you'll get something. I imagine this would be cheaper and easier for most, though it would take up a bit more space.

That being said, if you ARE familiar with Arduino, the possibilities here are endless. You could use the button to simultaneously trigger a flash, for example.
reado2 years ago
This instructable is soooo good.. But i had a slight modification that people maybe interested in. When my easy button was pressed down the Serial.println would print a new line every time the loop iterated. In my case, I only wanted to add one [enter] (or in my case, the letter 'g' to appear) instead of 100's. I modified the code to allow for a previous state variable that will only execute the Serial command once for the duration of a button press

const int buttonPin = 10;

// Variables that will change
int buttonState = 0;
int previousState = 0;

void setup() {
     // Initialize the button pin as an input
     pinMode(buttonPin, INPUT);
     Serial.begin(9600);
}

void loop() {
     // read the state of the pushbutton variable
     buttonState = digitalRead(buttonPin);

     // If the button is being pressed
     if(buttonState == HIGH) {
          // If the button is being held down then the previous state
          // will be checked and only if the previous state was LOW would it
          // display the character
          if(!previousState) {
               Serial.print('g');
          }
     }
     previousState = buttonState;
}
HatterAP2 years ago
I was just about to build this very same thing and then I saw this post! Maybe not a giant camera, but that's still pretty cool. It took me only a few minutes to set this up with a simple button, tomorrow I'll be buying the "Easy Button" and complete the build.

I love my Arduino.

Great job!