element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Open Arduino
  • Challenges & Projects
  • Project14
  • Open Arduino
  • More
  • Cancel
Open Arduino
Blog IR intervalometer for camera
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Open Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kk99
  • Date Created: 8 Apr 2018 4:43 PM Date Created
  • Views 3488 views
  • Likes 12 likes
  • Comments 14 comments
  • ardintermediate
  • openarduinoch
Related
Recommended

IR intervalometer for camera

kk99
kk99
8 Apr 2018

image

The basic idea was to create IR intervalometer for my Nikon DSLR. I have found in network information about captured raw signal from existing Nikon ML-L3 remote control. So, I have decided to use this information and Arduino Uno to create IR time-lapse intervalometer device for Nikon DSLR. Original RAW IR signal is modulated with 38kHz frequency and have following timings:

- 2.0 ms - on

- 28.0  ms - off

- 0.5 ms - on

- 1.5 ms - off

- 0.5 ms - on

- 3.5 ms - off

- 0.5 ms - on

- 63.5 ms - off

 

First step was to create a shield for arduino with support for IR LED and one button. IR diode is driven by NPN transistor to achieve 35 mA of current and larger distance for control. Button it pulled-up to 5 volt. Here is schematic:

image

Second step was to create program. Value of current interval for time-lapse is stored in EEPROM and it is possible to update it by USB serial by sending command:

- setInterval:12345 (five digit value of interval in seconds). I have used two libraries:

- first for button debouncing. Here is library source: https://github.com/thomasfredericks/Bounce2

- second for driving IR LED. Here is library source: https://github.com/z3t0/Arduino-IRremote

image

Here is flow diagram for program:

image

Source code is also available in attachment.

/*
   Basic IR intervalometer for Nikon DSLC cameras
   by kk99
   2018
*/

#include 
#include 
#include 

IRsend irSend;
Bounce debouncer = Bounce();

const int BUTTON_PIN = 2;
const unsigned long DEFAULT_TIMELAPSE_INTERVAL_SEC = 5;
const int EEPROM_ADDRESS = 0;
bool isWorkingMode = false;
bool requestNextPhoto = false;
bool isUpdateTimelapseInterval = false;
unsigned int timelapseIntervalValueToUpdate = 0;
unsigned long timelapseIntervalMs = 0;
unsigned long lastPhotoTime = 0;

unsigned long getTimelapseInterval(void)
{
  unsigned long timelapseIntervalVal = 0;
  EEPROM.get(EEPROM_ADDRESS, timelapseIntervalVal);
  return timelapseIntervalVal;
}

void setTimelapseInterval(unsigned long timelapseIntervalVal)
{
  EEPROM.put(EEPROM_ADDRESS, timelapseIntervalVal);
}

void takePhoto(void)
{
  // modulation frequency in kilohertz
  int frequency = 38;
  // signal for take a photo by Nikon DSLR
  unsigned int irSignal[] = {2000, 28000, 500, 1500, 500, 3500, 500, 63500};
  irSend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), frequency);
}

void workingModeLED(bool on)
{
  if (on) {
    digitalWrite(LED_BUILTIN, HIGH);
  } else {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

void setup() {
  // initialize serial communication
  Serial.begin(9600);
  // initialize digital pin for builtin status LED as an output
  pinMode(LED_BUILTIN, OUTPUT);
  workingModeLED(false);

  // initialize digital pin for button as an input
  pinMode(BUTTON_PIN, INPUT);
  // setup button debouncer
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(50);

  // read timelapse interval in seconds
  unsigned long tempTimelapseIntervalVal = getTimelapseInterval();
  if (tempTimelapseIntervalVal == 0) {
    Serial.println("Restored default value of time-lapse interval");
    tempTimelapseIntervalVal = DEFAULT_TIMELAPSE_INTERVAL_SEC;
    setTimelapseInterval(tempTimelapseIntervalVal);
  }
  timelapseIntervalMs = tempTimelapseIntervalVal * 1000;
  Serial.println("Intervalometer initialized");
}

void loop() {
  // update time
  unsigned long timestamp = millis();

  // check button state
  debouncer.update();
  bool buttonState = debouncer.fell();
  if (buttonState) {
    isWorkingMode = !isWorkingMode;
  }

  // update status LED
  workingModeLED(isWorkingMode);

  if (isWorkingMode) {
    // check timelapse interval
    if (requestNextPhoto) {
      unsigned long diffMs = timestamp - lastPhotoTime;
      if (diffMs > timelapseIntervalMs) {
        requestNextPhoto = false;
      }
    }

    // take a photo
    if (!requestNextPhoto) {
      Serial.println("Captured picture");
      takePhoto();
      requestNextPhoto = true;
      lastPhotoTime = timestamp;
    }
  } else {
    requestNextPhoto = false;
    lastPhotoTime = 0;
    if (isUpdateTimelapseInterval) {
      unsigned long currentTimelapseInterval = timelapseIntervalMs / 1000;
      if (currentTimelapseInterval != timelapseIntervalValueToUpdate) {
        setTimelapseInterval(timelapseIntervalValueToUpdate);
        timelapseIntervalMs = timelapseIntervalValueToUpdate * 1000;
        Serial.println("Updated value of time-lapse interval");
      }
      isUpdateTimelapseInterval = false;
    }
  }
}

void serialEvent() {
  if (isUpdateTimelapseInterval) {
    return;
  }

  const int dataLength = 18;
  if (Serial.available() < dataLength - 1) {
    return;
  }

  int i = 0;
  char receivedData[dataLength] = { 0 };
  while (Serial.available() > 0) {
    char character = Serial.read();
    if (i < dataLength - 1) {
      receivedData[i] = character;
    }
    i++;
  }

  char *data = strstr(receivedData, "setInterval:");
  if (data) {
    data += 12;
    int timelapseIntervalVal = atoi(data);
    if (timelapseIntervalVal > 0) {
      Serial.println("Got new value of time-lapse interval in seconds:");
      Serial.println(timelapseIntervalVal);
      isUpdateTimelapseInterval = true;
      timelapseIntervalValueToUpdate = timelapseIntervalVal;
    }
  }
}

Here is example video of remote controlling of Nikon DSLR:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Attachments:
code.zip
  • Sign in to reply

Top Comments

  • kk99
    kk99 over 7 years ago in reply to genebren +4
    Thank you. I am using it to create time-lapse videos. Most of new cameras have this function built-in. Here is an example: www.youtube.com/watch
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to mcb1 +4
    I will publish one project soon before the deadline, based on Arduino, obviously, with some improvements than a bare intervalometer. Stay in touch Enrico
  • genebren
    genebren over 7 years ago +3
    Nice like project. I had to lookup intervalometer to really understand what you were doing. Very cool. Gene
  • Gough Lui
    Gough Lui over 7 years ago

    Nice to see someone doing such a project - it's potentially quite handy and something I envisaged when I actually analyzed the code of a Nikon ML-L3 remote back in 2013 and emulated it on an Arduino.

    http://goughlui.com/2013/12/06/teardown-and-project-clone-nikon-ml-l3-ir-remote-and-emulation/

     

    Good to see the timings you used match the timings I measured exactly.

     

    - Gough

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to mcb1

    I will publish one project soon before the deadline, based on Arduino, obviously, with some improvements than a bare intervalometer. Stay in touch image

     

    Enrico

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 7 years ago in reply to kk99

    Do you have any suggestions to settings/options which I could add to this device ?

    You might want to download the code, add an LCD and fire it up. ... it reads analogue for the buttons, so you can probably fudge it, I do have the schematic.

     

     

    The instruction manual is there as well, so it will give you some ideas.

     

    Number of shots, time to allow the camera to prefocus, time between shots would be three off the top of my head.

     

     

    Cheers

    mark

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kk99
    kk99 over 7 years ago in reply to mcb1

    Yes, I need to think about end to end device like you wrote with LCD screen, physical interface and dedicated MCU. Do you have any suggestions to settings/options which I could add to this device ?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 7 years ago in reply to kk99

    The plug in Intervalometer had a few options ... but nowhere the flexibility a custom piece of hardware could provide.

     

    If you ever get to ver2.0, you may want to include LCD and a physical output.

     

     

     

     

    I really do need to progress that mutiple option camera trigger I found ... it needed a pcb designed and I stopped there. image

     

    Mark

    edit some characters decided to escape .... I've replaced them with new ones.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube