{"id":333,"date":"2011-08-15T23:10:52","date_gmt":"2011-08-15T13:40:52","guid":{"rendered":"http:\/\/www.l8ter.com\/?p=333"},"modified":"2011-10-21T10:00:57","modified_gmt":"2011-10-21T00:30:57","slug":"arduino-timelapse-ir-remote-for-nex-5","status":"publish","type":"post","link":"http:\/\/www.l8ter.com\/?p=333","title":{"rendered":"Arduino Timelapse IR remote for NEX-5"},"content":{"rendered":"            <script type=\"text\/javascript\" src=\"http:\/\/www.l8ter.com\/wp-content\/plugins\/wordpress-code-snippet\/scripts\/shBrushPhp.js\"><\/script>\n<p>I have recently beeing getting into timelapse, My major problem was that i wanted to use the Sony NEX-5 to take the shots, the issue with this camera is it only has IR as a trigger. There are a variety of items out there that\u00a0achieve\u00a0this task (<a href=\"http:\/\/www.gentles.ltd.uk\/gentled\/auto.htm\">gentles<\/a> , \u00a0<a href=\"http:\/\/tempusall.bymac.org\/\">tempus<\/a> , <a href=\"http:\/\/www.pclix.com\/product-information\/pclix-xt-feature-set\">PclixXT<\/a>) But they all are a tad large, have no real easy way to attach to the cameras sensor. I also wanted one now and didnt want to wait a month for it to arrive in the mail. I already had an IR controller for the camera ($5 ebay special) and I ripped it\u00a0apart\u00a0and crudely soldered two wires to the button, So when the wires completed the circuit the remote fired.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-352\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/wiredremote-494x275.jpg\" alt=\"\" width=\"494\" height=\"275\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/wiredremote-494x275.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/wiredremote-288x160.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/wiredremote-800x446.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/wiredremote.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/p>\n<p>I then went to Jaycar and Purchased a timer, a friend at work soldered it up for me as i\u00a0wasn&#8217;t\u00a0confident in my abilities. I also mounted the timer in a case, this time ran off 8 AA batteries.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-353\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/timer-controller-494x275.jpg\" alt=\"\" width=\"494\" height=\"275\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/timer-controller-494x275.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/timer-controller-288x160.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/timer-controller-800x446.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/timer-controller.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/p>\n<p>I bent the IR led in the remote towards the back and drilled a hole for it, i then velcroed this to the front of the camera.\u00a0I took this out for our first official timelapse test, we wernt sure if we could even get the shots we were after but this is what we ended up with:<\/p>\n<p><object width=\"640\" height=\"390\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/EZ3c9lgWzrg?version=3&amp;hl=en_US&amp;hd=1\" \/><param name=\"allowfullscreen\" value=\"true\" \/><embed width=\"640\" height=\"390\" type=\"application\/x-shockwave-flash\" src=\"http:\/\/www.youtube.com\/v\/EZ3c9lgWzrg?version=3&amp;hl=en_US&amp;hd=1\" allowFullScreen=\"true\" allowscriptaccess=\"always\" allowfullscreen=\"true\" \/><\/object><\/p>\n<p>From this 2 hour test, I found a major issue. The timer i was using was mechanical and they\u00a0don&#8217;t\u00a0like low current (or so i read) and this caused the remote not to fire every now and then (Sometimes 3 times in a row). This just\u00a0wouldn&#8217;t\u00a0do, so back to the drawing board.<\/p>\n<p>I was sitting at home and I stumbled upon an <a href=\"http:\/\/luckylarry.co.uk\/arduino-projects\/arduino-ir-remote-intervalometer-for-nikon-d80-that-means-timelapse-photography-yarrr\/\">Arduino powered Nickon D80 IR Intravoltmeter<\/a>\u00a0. This site was great, I had an Arduino sitting in a box doing nothing, so all i needed was an IR LED and maybe a resistor. Sure enough it was pretty much a copy and paste job. Problem now was getting the IR code for the Sony NEX camera. Luckily there is a device called the Pronto that captures codes, and people share this freely (Phillips Pronto Code), and sure enough i <a href=\"http:\/\/dp-master1.dpreview.com\/forums\/readflat.asp?forum=1042&amp;message=38672566&amp;changemode=1\">found some<\/a>\u00a0. Now to figure out how to convert from pronto code to\u00a0something\u00a0i could use with the Arduino code from before. Originally I wrote some\u00a0obscure\u00a0excerl formulas to work it out, but in the end i build a script to convert. <strong>So if you want to convert pronto code into an on and off timing signal with IR Arduino Code give my script a whirl: <a href=\"http:\/\/l8ter.com\/arduino\/\">Pronto Code to pulse converter + Arduino Code Builder.<\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The circuit for this code is fairly straight forward. I however wanted a low battery warning (What would be worse then shooting for 30 minutes only to run out of batteries) I found another<a href=\"http:\/\/www.arduino.cc\/cgi-bin\/yabb2\/YaBB.pl?num=1193236786\"> ancient post<\/a>\u00a0explaining how to detect a low battery from a 9 volt battery. Here is the circuit:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-364\" title=\"ledlightcontroller 2_bb\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/ledlightcontroller-2_bb-494x333.jpg\" alt=\"\" width=\"494\" height=\"333\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/ledlightcontroller-2_bb-494x333.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/ledlightcontroller-2_bb-288x194.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/ledlightcontroller-2_bb-800x539.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/ledlightcontroller-2_bb.jpg 852w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/>A few things i dont show in the above image, 1. I wire the resistor and cable for the LED to a mono 3.5 plug. So I can easily plug and unplug the led. 2. i Put a switch on the positive so i can easily turn it on and off. This is a shot of the kit all put together:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-357\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02409-Large-494x276.jpg\" alt=\"\" width=\"494\" height=\"276\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02409-Large-494x276.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02409-Large-288x161.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02409-Large-800x448.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02409-Large.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/>At this early stage the LED looked like:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-358\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02413-Large-494x276.jpg\" alt=\"\" width=\"494\" height=\"276\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02413-Large-494x276.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02413-Large-288x161.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02413-Large-800x448.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02413-Large.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/>Problem i found here was it was impossible to mount with such a small field of view on the LED. And after 4 or 5 nights of use a dry joint formed on the resistor, i think this was due to the movement between shots. I built a new enclosure from an old IR mouse\u00a0receiver:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-359\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02415-Large-494x276.jpg\" alt=\"\" width=\"494\" height=\"276\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02415-Large-494x276.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02415-Large-288x161.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02415-Large-800x448.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02415-Large.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/>Again this worked but I still found it hard to ensure the LED could be seen by the camera even tho it was stuck right on top. I had a rethink and found that there is a thing called a remote blaster, these use an IR blaster these can be picked up at Jaycar for $8 and look like:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-large wp-image-361\" title=\"SONY DSC\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02416-Large-494x276.jpg\" alt=\"\" width=\"494\" height=\"276\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02416-Large-494x276.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02416-Large-288x161.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02416-Large-800x448.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2011\/08\/DSC02416-Large.jpg 1024w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/>Much smaller, professionally made, with the same 3.5 jack that will work with the female jack I used on my build. And It works great.<\/p>\n<p>This is the end of the version 1 build. Version 2 will have LCD and motor dolly control, also adjustable timer without needing to reprogram.<\/p>\n<p>Here is the final code for the Sony NEX Timelapse system:<\/p>\n<p><a href=\"http:\/\/www.l8ter.com\/arduino\/sketch_jul14a.pde\">Download<\/a><\/p>\n<p>&nbsp;<br \/>\n<pre class=\"brush: php\">\/*\r\nLUCKYLARRY.CO.UK - IR Remote control for Nikon using Arduino\r\nMimics the infrared signal to trigger the remote for any Nikon camera\r\nwhich can use the ML-L1 and ML-L3 remotes. Can be used as an intervalometer\r\nfor time lapse photography.\r\nThe IR sequence I used is originally taken from: http:\/\/www.bigmike.it\/ircontrol\/\r\nYou should be able to use my pulse methods to alter to suit other cameras\/ hardware.\r\nmicros() is an Arduino function that calls the time in Microseconds since your program\r\nfirst ran. Arduino doesn&#039;t reliably work with microseconds so we work our timings by\r\ntaking the current reading and then adding our delay on to the end of it rather than rely\r\non the in built timer.\r\n*\/\r\nint pinIRLED = 12; \/\/ assign the Infrared emitter\/ diode to pin 13\r\nint LEDgreen = 13; \/\/ use onboard led for battery status\r\nint batteryIn = 0; \/\/ set pin to get power data from\r\nint batLevel = 0; \/\/ variable to get details on battery power level from analog input\r\nint lowPower = 0; \/\/count to keep track of lowpower state\r\n\r\nvoid setup() {\r\n  pinMode(pinIRLED, OUTPUT);                            \/\/ set the pin as an output\r\n}\r\n\/\/ sets the pulse of the IR signal.\r\nvoid pulseON(int pulseTime) {\r\n  unsigned long endPulse = micros() + pulseTime;        \/\/ create the microseconds to pulse for\r\n  while( micros() &lt; endPulse) {\r\n    digitalWrite(pinIRLED, HIGH);                       \/\/ turn IR on\r\n    delayMicroseconds(13);                              \/\/ half the clock cycle for 38Khz (26.32&times;10-6s) - e.g. the &#039;on&#039; part of our wave\r\n    digitalWrite(pinIRLED, LOW);                        \/\/ turn IR off\r\n    delayMicroseconds(13);                              \/\/ delay for the other half of the cycle to generate wave\/ oscillation\r\n  }\r\n}\r\nvoid pulseOFF(unsigned long startDelay) {\r\n  unsigned long endDelay = micros() + startDelay;       \/\/ create the microseconds to delay for\r\n  while(micros() &lt; endDelay);\r\n}\r\nvoid takePicture() {\r\n  for (int i=0; i &lt; 2; i++) {\r\npulseON(2336);\r\npulseOFF(646);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(646);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(646);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(11008);\r\npulseON(2336);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(646);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(646);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(11008);\r\npulseON(2336);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(646);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1168);\r\npulseOFF(621);\r\npulseON(1093);\r\npulseOFF(696);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(621);\r\npulseON(572);\r\npulseOFF(1218);\r\npulseON(497);\r\npulseOFF(1292);\r\npulseON(422);\r\npulseOFF(1367);\r\npulseON(373);\r\npulseOFF(11803);\r\npulseON(298);\r\npulseOFF(2659);\r\npulseON(199);\r\npulseOFF(1590);\r\npulseON(174);\r\npulseOFF(1019);\r\npulseON(174);\r\npulseOFF(1615);\r\npulseON(174);\r\npulseOFF(1615);\r\npulseON(149);\r\npulseOFF(1044);\r\npulseON(149);\r\npulseOFF(1640);\r\npulseON(124);\r\npulseOFF(1093);\r\npulseON(149);\r\npulseOFF(1044);\r\npulseON(124);\r\npulseOFF(1665);\r\npulseON(124);\r\npulseOFF(1068);\r\npulseON(124);\r\npulseOFF(1665);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1118);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(75);\r\npulseOFF(1715);\r\npulseON(75);\r\npulseOFF(12101);\r\npulseON(149);\r\npulseOFF(2833);\r\npulseON(75);\r\npulseOFF(1715);\r\npulseON(75);\r\npulseOFF(1118);\r\npulseON(75);\r\npulseOFF(1715);\r\npulseON(75);\r\npulseOFF(1715);\r\npulseON(75);\r\npulseOFF(1118);\r\npulseON(75);\r\npulseOFF(1715);\r\npulseON(75);\r\npulseOFF(1118);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1118);\r\npulseON(99);\r\npulseOFF(1093);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(1690);\r\npulseON(99);\r\npulseOFF(646);\r\n  }                                                     \/\/ loop the signal twice.\r\n}\r\nvoid batterytestdelay(unsigned long delaytime){  \/\/ Function to check battery level and flash the led if its low battery\r\n  long tempdelay = 0;\r\n  while(delaytime &gt; tempdelay){\r\n    delay(100);\r\n    tempdelay = tempdelay + 100;\r\n     batLevel = analogRead(batteryIn);\r\n    if (batLevel &lt; 720){\r\n      lowPower++;\r\n    }\r\n    if (lowPower &gt; 100){\r\n      lowPower = 0;\r\n    }\r\n    if (lowPower &lt; 50){\r\n      digitalWrite(LEDgreen, LOW);\r\n    }\r\n    else{\r\n      digitalWrite(LEDgreen, HIGH);\r\n    }\r\n  }\r\n}\r\n\r\nvoid loop() {\r\n  digitalWrite(LEDgreen, HIGH);\r\n  takePicture();  \/\/ take the picture\r\n  digitalWrite(LEDgreen, LOW);\r\n  batterytestdelay(33000);                                          \/\/ delay in milliseconds which allows us to do timelapse photography - 1 second = 1000 milliseconds. This delay has been passed to the battery testing function\r\n}<\/pre><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have recently beeing getting into timelapse, My major problem was that i wanted to use the Sony NEX-5 to take the shots, the issue with this camera is it only has IR as a trigger. There are a variety&#8230; <a class=\"more-link\" href=\"http:\/\/www.l8ter.com\/?p=333\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,16,45],"tags":[],"_links":{"self":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/333"}],"collection":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":16,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":454,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions\/454"}],"wp:attachment":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}