Instructables

Step 9: Programming

Picture of Programming
Now is time to program the Arduino and test your setup.

Follows is my code:

/* Time-Lapse Camera Controller
  • ------------------
*
  • Hits a camera shutter at a set interval
  • for time-lapse photography. The rate of the
  • delay can be manipulated for unique effects.
*
*
*/

int camPin = 7; // sets the camera shutter pin
int stupidvar = 30000; // sets the delay between pictures

void setup()
{
pinMode(camPin, OUTPUT); // defines pin as an output
}

void loop()
{
digitalWrite(camPin, HIGH); // presses the button
delay(5000); // waits
digitalWrite(camPin, LOW); // release the button
delay(stupidvar); // delay between pictures

// stupidvar = stupidvar + 1000 // increments delay by one second for unique effect.

}
 
Remove these adsRemove these ads by Signing Up
Ryutso3 years ago
So how's it work? Turn the Arduino on, Turn the camera on and it just starts snapping pictures like mad?
randofo (author)  Ryutso3 years ago
Pretty much, the Arduino just keeps running at whatever interval you set. Simply connect them together and turn them both on.
Ryutso randofo2 years ago
So, do you need the 5V relay?
spystealth12 years ago
Wouldn't the relay just spit dangerous voltage back into the arduino's pins when it releases the switch? I think you might want to put a diode between the relay's pin or just use a transistor with it.