Arduino intervalometer

These days I’ve been on holidays to make some progress on a personal project I have with a friend. We are trying to make a camera dolly to record time lapse videos with our DSLR cameras. The project is powered by an Arduino board, but as my experience with electronics is null, so I decided to make a little test project first as an introduction.

The result is a very simple intervalometer, built with a few components, a potenciometer to adjust the time between shots, an optoisolator to trigger a Canon camera by cable and an IR led to trigger a Nikon camera.
The schematic is the following.

And here is the source code running on the Arduino. I should rewrite it to not make use of the delay function.

#include "NikonRemote.h"

const int potPin = A0;
const int ledPin = 13;
const int irPin = 8;
const int jackPin = 12;

// config values
const int minDelay = 100;
const int blinkLength = 150;
const int canonPulseLength = 40;

NikonRemote camera(irPin);

void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(jackPin, OUTPUT);

void loop() { 
  int val = (analogRead(potPin) * 20) - blinkLength;
  if (val < minDelay) {
    val = minDelay;
  Serial.print("Analog read: ");
  Serial.println(val, DEC);


void snap() {
  // blink status led
  digitalWrite(ledPin, HIGH);
  // snap nikon
  // snap canon
  digitalWrite(jackPin, HIGH);
  digitalWrite(jackPin, LOW);
  // end blink
  delay(blinkLength - canonPulseLength);
  digitalWrite(ledPin, LOW);