Triggy, The Automatic Camera Trigger

Triggy is an Arduino-based, open source intervalometer which is capable of using the infrared trigger on Nikon cameras to take photos at regular and dynamic intervals. We used a simplified version of Triggy to create the forsythia time lapse movie. You could build more complicated projects by adding additional code and hardware.

Triggy Wiring Diagram

This version of Triggy has 3 speeds to select from, as well as the ability to trigger photos with a photocell when the ambient light gets suddenly brighter or dimmer. That would allow it to work as a device that is triggered by the flashes of other cameras, sort of like Julius von Bismarck’s Image Fulgurator.

Here is the code for our basic protype:

/*

Created by Mount Holyoke students and Nick Baker at the MHC Media Lab, 2013.
Built on code from: LUCKYLARRY.CO.UK - IR Remote control for Nikon using Arduino
and http://www.bigmike.it/ircontrol/
https://mhcmedialab.wordpress.com
This work is licensed under a 
Creative Commons Attributions-ShareAlike 3.0 Unported License
*/

int photocellPin = 1; // the cell and 10K pulldown are connected to a0
int photocellReading=0; // the analog reading from the sensor divider
float photocellAverage;
int photocellAverageOver=20;
int delayPicture;
int pinIRLED = 8; // assign the Infrared emitter/ diode to pin 12

int potPin = 0; // select the input pin for the potentiometer
// three pins to indicate the level
int led1Pin = 9;
int led2Pin = 10;
int led3Pin = 11;
int led4Pin = 12;
int led5Pin = 13;

int val = 0; // variable to store the value coming from the sensor
int delayCount = 0;
int delayMax = 10;

void setup() {
// declare the ledPin as an OUTPUT
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);
pinMode(led4Pin, OUTPUT);
pinMode(led5Pin, OUTPUT);
pinMode(pinIRLED, OUTPUT); // set the pin as an output
Serial.begin(9600);

}

// sets the pulse of the IR signal.
void pulseON(int pulseTime) {
unsigned long endPulse = micros() + pulseTime; // create the microseconds to pulse for
while( micros() < endPulse) {
digitalWrite(pinIRLED, HIGH); // turn IR on
delayMicroseconds(13); 
// half the clock cycle for 38Khz (26.32×10-6s) - e.g. the 'on' part of our wave
digitalWrite(pinIRLED, LOW); // turn IR off
delayMicroseconds(13); 
// delay for the other half of the cycle to generate wave/ oscillation
}

}

void pulseOFF(unsigned long startDelay) {
unsigned long endDelay = micros() + startDelay; // create the microseconds to delay for
while(micros() < endDelay);
}

void takePicture() {
digitalWrite(led5Pin, HIGH);
for (int i=0; i < 2; i++) {
pulseON(2000); // pulse for 2000 uS (Microseconds)
pulseOFF(27850); // turn pulse off for 27850 us
pulseON(390); // and so on
pulseOFF(1580);
pulseON(410);
pulseOFF(3580);
pulseON(400);
pulseOFF(63200);
} // loop the signal twice.
digitalWrite(led5Pin, LOW);
}

void loop() {
photocellReading = analogRead(photocellPin);
photocellAverage=
(((photocellAverageOver-1)*photocellAverage)+photocellReading)/photocellAverageOver;
Serial.print("reading is: ");
Serial.println(photocellReading);
Serial.print("average is: ");
Serial.println(photocellAverage);

Serial.print("percentage is: ");
Serial.println(abs(photocellReading-photocellAverage)/photocellAverage);

int pin = map(analogRead(potPin), 0, 1023, 9, 12); //Serial.println(pin);
if (pin==12){
for(int i=9; i<=11; i++) { digitalWrite(i, LOW); } 
digitalWrite(pin, HIGH); 
if ((abs(photocellReading-photocellAverage)/photocellAverage)>.05){
photocellAverage=photocellReading;
takePicture();
}

}
else{
for(int i=9; i<=12; i++) { 
if(i == pin) { 
digitalWrite(i, HIGH); 
if(i==9) { delayMax = 20; } // 2 seconds 
if(i==10) { delayMax = 60; } // 6 seconds 
if(i==11) { delayMax = 600; } // 1 minute 
} else { digitalWrite(i, LOW); } 
} Serial.println(delayCount + ", " + delayMax); 
if(delayCount++ >= delayMax) {
takePicture();
delayCount = 0;
}
}

delay(100); // pause for a tenth of a second

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s