Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Thursday, June 16, 2011

Sound Triggered Camera Flash

After reading an article on @diyphotography on a Sound and Optical Slave Flash Trigger, I decided make a sound trigger using an Arduino.

An old computer headset is connected to a simple NPN transistor amplifier circuit and fed into one of the Arduino's analog inputs.
When the user defined threshold of sound is met, a digital pin goes HIGH. The pin is connected to a 4n35 optoisolator (scavenged from a USB charger unit) to short the contacts of the flash unit and fire the flash.

There are three LEDs which indicate the current state of the trigger unit.
Red LED (Configuration state):
The Arduino continuously listens for the sound differential between the present level and from 1us before. The analog input of the Arduino represents the voltage level from 0-5v as 0-1023. When a difference of sound of 40 or greater is detected, it is set as the current threshold to flash the trigger and the program proceeds to the test state.

Yellow LED (Test State):
In this state, the flash trigger can be tested for proper functionality. Instead of triggering a flash, an LED is lit when the sound threshold is met. When the user presses the start button, the test state is exited and proceeds to the active state.

Green LED (Active State):
In this state, the Arduino is waiting for a sound within the desired threshold to trigger the flash unit.

If the reset button is pressed the flash trigger is brought back to the configuration state.

The following is the code for the flash trigger:


int sensorPin = 0;
int sensorValue = 0;
int state = 0;
int resetPin = 6;
int startPin = 7;
int threshold = 0;
int ledPin = 5;
int flashPin = 8;
int diff = 0;
int configLED = 2;
int testLED = 3;
int activeLED = 4;

void setup() {
Serial.begin(9600);
pinMode(resetPin, INPUT);
pinMode(startPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(configLED, OUTPUT);
pinMode(testLED, OUTPUT);
pinMode(activeLED, OUTPUT);
pinMode(flashPin, OUTPUT);
}

void loop() {
if(digitalRead(resetPin) == HIGH){
state = 0;
digitalWrite(ledPin, LOW);
digitalWrite(testLED, LOW);
digitalWrite(activeLED, LOW);
}
else{
switch(state){
case 0 : //define trigger threshold
Serial.println(state);
digitalWrite(configLED, HIGH);
sensorValue = analogRead(sensorPin);
delayMicroseconds(1);
//compare present value with value from 1us before
diff = abs(sensorValue - analogRead(sensorPin));
if(diff > 30){
threshold = diff;
digitalWrite(configLED, LOW);
state = 1;
}
else state = 0;

break;

case 1 : //test trigger with LED
Serial.println(state);
Serial.println(threshold);
if(digitalRead(startPin) == HIGH){ //exit case if start button is pressed
state = 2;
digitalWrite(testLED, LOW);
}
else{
digitalWrite(testLED, HIGH);
sensorValue = analogRead(sensorPin);
delayMicroseconds(1);
//compare present value with value from 1ms before
diff = abs(sensorValue - analogRead(sensorPin));
if(diff >= threshold){
digitalWrite(testLED, LOW);
delay(200);
digitalWrite(testLED, HIGH);
}
}
break;

case 2 : //active mode, wait for sound within threshold
Serial.println(state);
digitalWrite(activeLED, HIGH);
sensorValue = analogRead(sensorPin);
delayMicroseconds(1);
//compare present value with value from 1ms before
diff = abs(sensorValue - analogRead(sensorPin));
if(diff >= threshold){
digitalWrite(flashPin, HIGH);
Serial.println("FLASH!!");
digitalWrite(flashPin, LOW);
delay(4000);
}
else
digitalWrite(flashPin, LOW);
break;
}
}
}
--------------------------

Tuesday, February 1, 2011

Remote Shutter Release

I own an Olympus E-PL1 and I love the camera but one thing I wish it has is a remote shutter release.

I first wanted to make a mechanical shutter release adapter similar to ones for the Sigma DP1 (http://www.amazon.com/Mechanical-Release-Adapter-exposure-photograph/dp/B003JFMYWA/ref=pd_rhf_p_t_2), but I would still need to buy a mechanical shutter release.

Looking through my closet for usable junk, I found my old remote control car which uses a servo for steering and a bunch of Legos.
I mounted the servo to the hot-shoe portion of a broken flash unit and I control the servo with an Arduino.

I programed the Arduino so that the system can be used as an intervalometer. The blue button on the left is used to enter the duration in seconds and the button on the right starts the shutter action. The RF module sitting on the board will be used later to release the shutter from a distance.