http://youtu.be/2KKv35tgPeY

Code:

 
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Intervaluino MaxTechTV Edition
// this code programs the Arduino as an intervalometer for a Canon EOS camera
// this enables you to create time-lapse movies with your camera.
// It features a LCD Display and two Pushbuttons to setup the interval and the amount of shots
// It uses two 4N35 Optocouplers to focus and release the shutter
//
//
// based on (c) Lord Yo 2008 (intervaluino a_t sporez do:t com) and extended by Max from MaxTechTV
// Licensed under a Creative Commons (Attribution Non-Commercial Share-Alike) license

int shutter = 10;               // goes to input of first 4N35
int focus = 9;                  // goes to input of second 4N35
int button1 = 6;                // left button
int button2 = 7;                // right button
int led = 13;                   // not used 
int val = A0;                   // not used

boolean button1_state = false;  // holds if a button is pressed or not
boolean button2_state = false;
int mode = 0;                   // used to navigate trough the GUI

int shutter_on = 200;           // how long the shutter is "pressed" (not how long the shutter is open!)
int focus_on = 300;             // time to let the camera get focus.
int wait = 200;                 // time between focus and shutter

int interval = 1000;            // start interval
int pics = 1;                   // amount of pics

void setup() {

  Serial.begin(9600);

  lcd.begin(16, 2);
  lcd.print("Intervaluino");
  lcd.setCursor(0,1);
  lcd.print("MaxTechTV Ed.");
  delay(2000);

  pinMode(shutter, OUTPUT);             // Triggers the Shutter
  pinMode(focus, OUTPUT);               // Triggers the focus
  pinMode(button1, INPUT_PULLUP);       // Connects Button1 to intern PullUp Resistor
  pinMode(button2, INPUT_PULLUP);       // Connects Button2 to intern PullUp Resistor
  pinMode(led,OUTPUT);                  // Status LED
  buttoncheck();

  lcd.clear();

}

void loop() {


  ////////////////////////// SET INTERVAL //////////////////////////
  // Press&Hold Button 1 to increase Time, Confirm with Button 2  //
  //////////////////////////////////////////////////////////////////

  while (mode == 0){
    lcd.print("Interval in sec");
    while (mode == 0){
      lcd.setCursor(0,1);
      lcd.print((interval/1000));
      lcd.print(".");
      lcd.print(interval%1000);
      delay(100);
      buttoncheck();

      if (button1_state==true) {
        interval = interval+100;
      } 
      if (button2_state== true){
        mode = 1;
        lcd.clear();
        delay(500);
      } 
    } 
  }

  //////////////////////// CONFIRM INTERVAL ////////////////////////
  //   Press Button 1 to go back or Press Button 2 to Confirm     //
  //////////////////////////////////////////////////////////////////

  while (mode == 1){

    lcd.print("Your Interval:");
    lcd.setCursor(0,1);
    lcd.print((interval/1000));
    lcd.print(".");
    lcd.print(interval%1000); 
    lcd.setCursor(5,1);
    lcd.print("OK?");
    delay(50);

    while ( mode == 1){
      buttoncheck();

      if (button1_state == true){
        mode = 0;
        interval = 1000;
        lcd.clear();
        delay(500);
      }
      if (button2_state == true){
        mode = 3;
        interval = interval-700;
        lcd.clear();
        delay(500);
      }
    } 
  }


  /////////////////////////// SET AMOUNT /////////////////////////////
  // Press&Hold Button 1 to increase Amount, Confirm with Button 2  //
  ////////////////////////////////////////////////////////////////////

  while (mode == 3){
    lcd.print("Amount of Shots");
    while (mode == 3){
      lcd.setCursor(0,1);
      lcd.print(pics);
      delay(50);
      buttoncheck();

      if (button1_state==true) {
        pics++;
      } 
      if (button2_state== true){
        mode = 4;
        lcd.clear();
        delay(500);
      } 
    } 
  }

  ///////////////////////// CONFIRM AMOUNT /////////////////////////
  //   Press Button 1 to go back or Press Button 2 to Confirm     //
  //////////////////////////////////////////////////////////////////

  while (mode == 4){

    lcd.print("Amount of Pics:");
    lcd.setCursor(0,1);
    lcd.print(pics); 
    lcd.setCursor(5,1);
    lcd.print("OK?");
    delay(50);

    while ( mode == 4){
      buttoncheck();

      if (button1_state == true){
        mode = 3;
        pics = 0;
        lcd.clear();
        delay(500);
      }
      if (button2_state == true){
        mode = 5;
        lcd.clear();
        delay(500);
      }
    } 
  }


  //////////////////// WAIT TO START SEQUENCE //////////////////////
  //                Countdown to start Sequence                   //
  //////////////////////////////////////////////////////////////////

  while (mode == 5){
    lcd.write("Start in :");    
    for (int k = 3 ; k>0; k--){
      lcd.setCursor(1,1);
      lcd.print(k);
      delay(1000);
    }
    Serial.print(interval);
    mode =6;
    lcd.clear();
    lcd.print("Shooting");
  } 




  /////////////////////// SHOOTING SEQUENCE ////////////////////////
  //   Press Button 1 to go back or Press Button 2 to Confirm     //
  //////////////////////////////////////////////////////////////////

  while (mode == 6){
    lcd.setCursor(0,1);
    lcd.print(pics*((interval+700)/1000));
    lcd.print(" secs left");
    digitalWrite(focus, HIGH);    // turn focus on
    delay(focus_on);              // keep focus
    digitalWrite(focus, LOW);     // turn focus off
    delay(wait);                  //wait
    digitalWrite(shutter, HIGH);  //press the shutter
    digitalWrite(led,HIGH);        //turn on status led
    delay(shutter_on);            //wait the shutter release time
    digitalWrite(shutter, LOW);    //turn of status led
    digitalWrite(led,LOW);        //release shutter
    pics--;                       //count pictures down
    delay(interval);              //wait for next round

    if (pics == 0){
      mode=7;
      lcd.clear();
      lcd.print("FINISHED...");
    }
  } 

}

void buttoncheck(){
  button1_state = !digitalRead(button1); // read state of Button 1
  button2_state = !digitalRead(button2); // read state of Button 2
}

Share