Arduino Camera Trigger: schematics, code & next steps

01.12.2014

IMG_3240

My first seed project is complete, with excellent results.  If you missed the pictures, check them out here, here, & here.

After a week of scraped-together after work hours, I planned, built, & tested the Arduino camera trigger, and took a ton of photos.  I feel much more comfortable with the Arduino after this project, and will definitely be building more in the months ahead.  The IDE & interface are easy to use, and the circuitry is pretty straightforward as well (at least for basic use).

Once I’ve worked through some more seed projects, I’m going to try and revisit this one, with a few thoughts on how to improve it:

  1. I’ll definitely want to wire this up on a protoshield, so I can keep it for future use while still working on more Arduino projects.
  2. It would be really handy to hook up a toggle switch to select which sensor is active, an analog knob to adjust the sensor delay, and a simple LCD display to indicate the current sensor & delay.  Shouldn’t take much effort, and I have all the parts, so hopefully I can tackle this soon.
  3. With a bit more time, it would be good to improve the structural setup of the studio – I used primarily cardboard to hold the components in place, where wood, metal or plastic would be far more reliable & durable.  I could also fix elements together (such as the housing for the laser and the housing for the photoresistor), which would definitely improve reliability.  And for water droplet photography, fastening the eye dropper to a device above the studio framework would eliminate any guesswork regarding how / when the sensors are triggered.
  4. Of course, I’ve only scratched the surface as far as photographs I can take with this setup, so if / when I return to this project, I’ll definitely try out some different lighting, objects, surfaces, and patterns.

For anyone interested in trying this out on their own, I’ve included the circuit diagram as well as my code below (I kept each component separate for simplicity).  Feel free to let me know if you have any questions!

diagram

Arduino code:


//Arduino Flash Trigger

const int lightSensorEnabled = 0;
const int soundSensorEnabled = 1;

//light detection
const int lightPin = 0; //the analog pin for the photoresistor
const int lightLedPin = 9;   //led connected to digital pin 10
const int lightThreshold = 100; //threshold value to decide when the light is broken - og: 50
const int lightFlashDelay = 130; //delay before triggering flash

//sound detection
const int soundLedPin = 10;      // led connected to digital pin 10
const int soundSensorPin = A1; // the piezo is connected to analog pin 1
const int soundThreshold = 0;  // threshold value to decide when the detected sound is loud enough
const int soundFlashDelay = 4; //delay before triggering flash

//flash trigger
const int cameraFlashPin = 4;
const int flashDelay = 5000;

void setup()
{
  //Serial.begin(9600);

  //light sensor
  pinMode(lightLedPin, OUTPUT); //sets the led pin to output

  //sound sensor
  pinMode(soundLedPin, OUTPUT); // declare the led pin as as OUTPUT

  //flash trigger
  pinMode(cameraFlashPin, OUTPUT); // declare the flash pin as OUTPUT
  digitalWrite(cameraFlashPin, LOW);
}

//triggers the flash on & off again
void triggerFlash() {
  digitalWrite(cameraFlashPin, HIGH);
  delay(100);
  digitalWrite(cameraFlashPin, LOW);
}

void loop()
{
  //light sensor
  if(lightSensorEnabled && analogRead(lightPin) > lightThreshold) {
    delay(lightFlashDelay);
    triggerFlash();
    digitalWrite(lightLedPin, HIGH);
    delay(flashDelay);  //delay for flash
  } else {
    digitalWrite(lightLedPin, LOW);
  }

  //sound sensor - if the sensor reading is greater than the threshold, show light
  if (soundSensorEnabled && analogRead(soundSensorPin) > soundThreshold) {
    delay(soundFlashDelay);
    triggerFlash();
    digitalWrite(soundLedPin, HIGH);
    delay(flashDelay);  //delay for flash
  } else {
    digitalWrite(soundLedPin, LOW);
  }
}


Comments are closed.