Permalink
Browse files

Added worklight relay & more comments

  • Loading branch information...
1 parent cc786e0 commit c160d73c831fa89f9b9ff8831d80e280d3b586b1 @mrichardson23 committed Nov 4, 2010
Showing with 15 additions and 6 deletions.
  1. +15 −6 Arduino-Audio-Flash-Trigger.pde
@@ -2,7 +2,7 @@
This is a basic sound-detecting camera & flash trigger for Arduino.
Use a piezo element for the sensor (see http://www.arduino.cc/en/Tutorial/KnockSensor)
Use opto isolators (aka optocouplers) for the flash and camera triggers
- Camera must be in BULB mode for this to work.
+ Camera must be in BULB mode for shutter release to work
*/
#define BUTTON_PIN 5
@@ -12,36 +12,45 @@
#define LED_PIN 10
#define STANDBY 0
#define ACTIVE 1
+#define WORKLIGHT_RELAY 9
#define SENSOR_THRESHOLD 0
int mode = STANDBY;
-long flashDelayMS = 0;
+
+// For best results, set flashDelayMS according to what type
+// of shot you're doing. 0 seems best for balloon burst while
+// 10 seems best for shattering glass. YMMV.
+long flashDelayMS = 10;
void setup() {
pinMode(BUTTON_PIN, INPUT);
pinMode(CAM_TRIGGER_PIN, OUTPUT);
pinMode(FLASH_TRIGGER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
- digitalWrite(LED_PIN, HIGH);
+ pinMode(WORKLIGHT_RELAY, OUTPUT);
+ digitalWrite(LED_PIN, HIGH);
+ digitalWrite(WORKLIGHT_RELAY, HIGH); //turn the lights on
}
void loop() {
if (digitalRead(BUTTON_PIN) == HIGH)
{
mode = ACTIVE;
- delay(1000); // to give time to settle after button push
- digitalWrite(LED_PIN, LOW);
+ digitalWrite(WORKLIGHT_RELAY, LOW); // turn the lights off
+ delay(2000); // to give time for light to go down and settle after button push
+ digitalWrite(LED_PIN, LOW); // show we're ready
digitalWrite(CAM_TRIGGER_PIN, HIGH); // open the camera shutter
}
if ((mode == ACTIVE) && (analogRead(SENSOR_PIN) > SENSOR_THRESHOLD)) //
{ //If we're in ACTIVE mode and we sense a pop:
delay(flashDelayMS);
- digitalWrite(FLASH_TRIGGER_PIN, HIGH);
+ digitalWrite(FLASH_TRIGGER_PIN, HIGH); // fire flash
delay(50);
digitalWrite(FLASH_TRIGGER_PIN, LOW);
digitalWrite(CAM_TRIGGER_PIN, LOW); // close camera shutter
mode = STANDBY;
digitalWrite(LED_PIN, HIGH);
+ digitalWrite(WORKLIGHT_RELAY, HIGH); // turn lights back on
}
}

0 comments on commit c160d73

Please sign in to comment.