Sunday, November 27, 2011

DIY: Photo Booth - Teensy


The Teensy USB Development Board was used in my DIY Photo Booth Project to add arcade style buttons to the enclosure to enable the user to switch between Photo and Video Modes, Start the image/video capture, and enable/disable the camera's live view. I originally had one button to activate Photo Mode, and a different button to activate Video mode. However, I found that dSLR Remote Pro had a simpler keyboard shortcut that could alternate between both photo and video modes. Here is my original sketch planning on how I would use Teensy.


The big Green button is LED backlit, and will be used to initiate either the Photo or Video countdown. Wiring was simple and straight forward. Power to the Teensy is provided by the USB Cable going to the PC. I found other teensy projects that were similar and used online documentation to figure out how to wire up the board properly. Some people used resistors and power from the teensy, but I kept it as simple as possible.



You can used compiled C programming code, or Arduino to configure the Teensy. I used Arduino, and here is my script that was uploaded to the Teensy. The final version had the big green button simulating a left click of the mouse, the black button to toggle live view (F6 button), and the yellow button to toggle back and forth between Photo and Video modes. (CTRL-S)


/*
Photobooth LED Buttons
*/
// Setting variables that correspond to the PIN numbers that
const int boothStart = 8; // Green Start Button - 8
const int liveViewMode = 4; // Live View Mode Toggle - 6
const int videoPhotoMode = 6; // Photo / Video Mode Toggle Button - 4
int startButtonStatus = 0;
int liveViewButtonStatus = 0;
int cameraButtonStatus = 0;
void setup() {
pinMode(boothStart, INPUT);
pinMode(liveViewMode, INPUT);
pinMode(videoPhotoMode, INPUT);
}
void loop(){

// Check Button Status
startButtonStatus = digitalRead(boothStart);
liveViewButtonStatus = digitalRead(liveViewMode);
cameraButtonStatus = digitalRead(videoPhotoMode);

// If boothStart button is pressed
if (startButtonStatus == HIGH) {
Mouse.set_buttons(1, 0, 0); // click left button
// delay(100);
Mouse.set_buttons(0, 0, 0); // release buttons
delay(500);
}
// If liveViewButton button is pressed
if (liveViewButtonStatus == HIGH) {
Keyboard.set_key1(KEY_F6);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
}

// If cameraMode button is pressed
if (cameraButtonStatus == HIGH) {
Keyboard.set_modifier(MODIFIERKEY_CTRL);
Keyboard.set_key1(KEY_S);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
}
}


1 comment:

  1. I tried verifying the code in Arduino 1.0.1 and it claims that 'Mouse' is only supported in Arduino Leonardo, am I missing something?

    ReplyDelete