Sunday, 29 July 2012 12:58

ATTiny45/ATTiny85 Arduino based Camera Control

ATtiny45/ATtiny85 Arduino based Camera Control ATtiny45/ATtiny85 Arduino based Camera Control
Digisnap 2000 (Electronic shutter release) is powerful but expensive. This project replacing Digisnap 2000 with very simple function.

 

Why select ATtiny85 for this project
1. It is very small, very cheap, simple to built and less power consumption compare to Arduino Development Board 
2. With higher flash memory, but cheaper price than ATtiny45
3. It consume a little power and so can power with solar cell. 


 

How to use this device
If the device is power on at 7am, it will trigger upon first power on, it also trigger the camera every 3 hours until 7pm, each day will capture 5 photos. You may modify the source code to suite for your own settings.
Note: This project did not use the RTC (Real Time Clock) module such as DS1307, the clock will reset to 0 sec, 0 minute, 0 hour, 01 day, 01 month, 01 year for every power on.

  

Download
This project is based on Tiny Arduino, see http://hlt.media.mit.edu/?p=1695 for details.
Tiny Arduino Shutter Release Source code: http://www.divshare.com/download/18556704-987
Camera remote release pinout list: http://www.doc-diy.net/photo/remote_pinout/#canon
 
ATTiny85 Arduino source code
  1. #include <Time.h> //include date time function such as hour(), minute(), second()
  2. #include <avr/sleep.h>
  3. #include <avr/wdt.h>
  4. const int cameraTriggerPin = 0; // TINY45 PIN5 as output
  5. const int cameraLEDPin = 2; // TINY45 PIN7 as output
  6. // Variables will change:
  7. int ledState = LOW; // ledState used to set the LED
  8. long previousMillis = 0; // will store last time LED was updated
  9. long interval = 1000; // interval at which to blink (milliseconds)
  10. void setup() {
  11. //OSCCAL= 0x6b;
  12. pinMode(cameraTriggerPin, OUTPUT); // set the digital pin as output
  13. pinMode(cameraLEDPin, OUTPUT); // set the digital pin as output
  14. digitalWrite(cameraTriggerPin, LOW);
  15. delay(3000); //waiting camera to ready
  16. enterSleep();
  17. setTime(0,0,0,01,01,01); //setTime(hr,min,sec,day,month,yr);
  18. //cameraTrigger(); //shoot once on startup
  19. }
  20. void loop()
  21. {
  22. unsigned long currentMillis = millis();
  23.  
  24. if(currentMillis - previousMillis > interval) {
  25. // save the last time you blinked the LED
  26. previousMillis = currentMillis;
  27. // if the LED is off turn it on and vice-versa:
  28. if (ledState == LOW)
  29. ledState = HIGH;
  30. else
  31. ledState = LOW;
  32. // set the LED with the ledState of the variable:
  33. digitalWrite(cameraLEDPin, ledState);
  34. }
  35. // if the device is turned on at 7am, then hour=0, min=0, sec=0 will be 7am
  36. // the device will be triggered every 3 hours until 7pm
  37. if (hour()==0 &amp;&amp; minute()==0 &amp;&amp; second()==0) cameraTrigger(); //7am
  38. if (hour()==3 &amp;&amp; minute()==0 &amp;&amp; second()==0) cameraTrigger(); //10am
  39. if (hour()==6 &amp;&amp; minute()==0 &amp;&amp; second()==0) cameraTrigger(); //1pm
  40. if (hour()==9 &amp;&amp; minute()==0 &amp;&amp; second()==0) cameraTrigger(); //4pm
  41. if (hour()==12 &amp;&amp; minute()==0 &amp;&amp; second()==0) cameraTrigger(); //7pm
  42. }
  43. void cameraTrigger(void)
  44. {
  45. //digitalWrite(cameraLEDPin, HIGH);
  46. digitalWrite(cameraTriggerPin, HIGH);
  47. delay(600); //delay 600ms
  48. //digitalWrite(cameraLEDPin, LOW);
  49. digitalWrite(cameraTriggerPin, LOW);
  50. }
  51. void enterSleep(void)
  52. {
  53.  
  54. set_sleep_mode(SLEEP_MODE_IDLE);
  55.  
  56. sleep_enable();
  57.  
  58. sleep_mode();
  59.  
  60. /** The program will continue from here. **/
  61.  
  62. /* First thing to do is disable sleep. */
  63. sleep_disable();
  64.  
  65. }
  66.  
  67. <div class="moduletable">
  68. <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  69. <!-- Automatic_size -->
  70. <ins class="adsbygoogle"
  71. style="display:block"
  72. data-ad-client="ca-pub-1526852759622810"
  73. data-ad-slot="2215374865"
  74. data-ad-format="auto"></ins>
  75. <script>
  76. (adsbygoogle = window.adsbygoogle || []).push({});
  77. </script> </div>
  78.  
  79.  

 

  

Enable Tiny Arduino
If this site http://hlt.media.mit.edu/?p=1695 is too complicated for you. Here is the Tiny Arduino I downloaded previously, it should work with arduino-0022 & arduino-0023. If you are running Windows XP, just download it to your computer & extract to My Documents/Arduino/Hardware folder (You should have My Documents/Arduino/Hardware/attiny folder in your computer) . Click on Board from Arduino Tools menu, you should see ATtiny45 & ATtiny85 appear in the Board menu.
Arduino Boards

 

Compile the ATtiny85 micro controller
You can use ATTiny45 or ATTiny85 for this project. Here I'm using ATTiny85.
1. Run the Arduino, I'm using Arduino 0022, make sure you already install Tiny Arduino & Time library.
2. Load the pde source code.
2. Select Board from Tools menu.
3. Select ATtiny85 (internal 1 MHz clock). See picture above
4. Click on Verify icon to start compiling
5. If you are running Windows XP, the hex file is saved in Documents and Settings\Windows XP\Local Settings\Temp\buildxxxxxxxxxxxxxxxxx.tmp folder
6. Use your programmer to flash the hex file to the micro controller.

 

Additional Info
  • Both ATtiny45 & ATtiny85 can use in this project
  • PC817 is the most cheaper photo coupler that I can get.
  • R2 & LED1 is optional, I didn't use it for my project.
  • You can use 8MHz crystal & 22pf capacitors for external clock source. Here I'm using AWCR series 8MHz ceramic resonator.
  • R1 value ranged from 330 ohms to 470 ohms, it use to limit the current flow through photo coupler. 

 

Fuse Settings
As shown in figure below is the fuse settings use to program the ATtiny85/ATtiny85 micro controller, I'm using AVR Studio4 & AVRISP MKII as the programmer.  Make sure enable CKDIV8 which will divide the 8Mhz by 8, so you get 1MHz of external clock source.

Fuse Settings

Read 21625 times Last modified on Sunday, 12 June 2016 11:51
Back to Top