Nikon Intervalometer with a Digispark

Years ago I bought myself an IR remote for my Nikon D40. That worked ok, but of course I wanted to build my own using a Digispark.

There’s lots of tutorials for IR remotes out there, like LuckyLarry’s. I then later came across the nikonIrControl library which basically allows you to trigger a photo with a single line of code! Best of it is this library will work for every camera supported by ML-L1 and ML-L3 such as D40, D40X, D50, D60, D70, D70s, D80, D90, D7000, D5000, D5100, D3000, Coolpix 8400, 8800, P6000, P7000, P7100, Nikon 1 J1/V1.

And because the intervalometer should be as tiny as possible I was using a Digispark to control everything.

Parts list:
Parts List

  • IR Led (940nm) with 470 ohm resistance
  • LED any color 3mm (status) with 220 ohm resistance
  • Digispark proto shield with header
  • 2 pin screw terminal block connector
  • 10k poti for the interval


As the signal emitted by the IR led is invisible to the human eye I decided to put in a green LED to indicate when the intervalometer triggers.
I hooked up the poti to pin 4 and map its value to a minimum of 5 seconds and the maximum to 14mins. This due to the fact that my D40 can stay up to 15min in the remote mode.
The 2 pin screw terminal block is connected to Digispark’s VIN and GND respectively. This to allow it to be powered by a battery or basically everything delivering between 7 and 35 volts.

And here’s some photos of my Digispark IR shield (not to be confused with the official Infrared Shield.)
IR shield bottom
IR shield top 1
IR shield top 2

And then on top of a Digispark:
IR shield on digispark 1
IR shield on digispark 2

And here’s the code:

 * Nikon D40 Intervallometer using a digispark
 * Nikon IR library downloaded from:

#include <nikonIrControl.h>

int CameraIrPin = 0;                // IR LED connected to digital pin 0
int LedPin = 1;                     // LED connected to digital pin 1
int PotiPin = 4;                    // interval poti at pin 4

// duration constants in secs
const long durationMin = 5;            // 5sec
const long durationMax = 840;          // 14min  (15 mins is the max my D40 can stay in remote mode)
long previousMillis = 0;
long interval = 1000;                  // interval at which to trigger (milliseconds)

void setup()                        // run once, when the sketch starts
  pinMode(CameraIrPin, OUTPUT);     // sets the digital pin as output
  pinMode(LedPin, OUTPUT);          // sets the digital pin as output
  pinMode(PotiPin, INPUT);          // poti = input

  // just do some blinking to show we're ready
  for(int i=0; i<5; i++) {
    digitalWrite(LedPin, HIGH);
    digitalWrite(LedPin, LOW);
  takePhoto();                      // first shot

void loop()                         // run over and over again
  // read the poti val
  // remember that digispark's pin 4 is Analog 2!!
  int duration = map(analogRead(2), 0, 1023, durationMin, durationMax);      

  // read millis counter
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > duration * interval) {
    // save the last time you triggered 
    previousMillis = currentMillis;     

    // take the photo at defined intervals. this depends on the poti.
    // it takes photos between 5secs and 10 minutes

void takePhoto(){
  digitalWrite(LedPin, HIGH);
  digitalWrite(LedPin, LOW);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.