// Written by Ryan Martin, Instructables user hacker3455 const int Bc = 11; // change this value for the pin value of the cycle button const int Ba = 12; // change this value for the pin value of accept button const int Sht = 13; // change this value for the pin value of shutter control byte PIN = 3; // change this value for the the pin value of lowest display pin float total = 0; //Arduino pins: 3,4,5,6,7,8,9 byte seven_seg_digits[10][7] = { { 1,1,1,1,0,1,1 }, // = 0 { 1,1,0,0,0,0,0 }, // = 1 { 0,1,1,0,1,1,1 }, // = 2 { 1,1,1,0,1,0,1 }, // = 3 { 1,1,0,1,1,0,0 }, // = 4 { 1,0,1,1,1,0,1 }, // = 5 { 1,0,0,1,1,1,1 }, // = 6 { 1,1,1,0,0,0,0 }, // = 7 { 1,1,1,1,1,1,1 }, // = 8 { 1,1,1,1,1,0,0 } // = 9 }; void setup() //initializing inputs and outputs { pinMode(Ba, INPUT); pinMode(Bc, INPUT); pinMode(Sht, OUTPUT); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); Serial.begin(9600); int one = cycle(); // retreiving number of minutes Serial.print ("minutes: "); Serial.println (one); int two = cycle(); //retreiving "tens" place of the seconds Serial.print ("seconds: "); Serial.print (two); int three = cycle(); //retreiving number of seconds Serial.println (three); one = one*60; // converting minutes to seconds two = two*10; // converting "tens" place to seconds total = one + two + three; // adding togeather all seconds Serial.print ("total seconds: "); Serial.print (total); total = total - 1; // subtracting 1 second because the program holds shutter for 1 second total = total * 1000; // multiplying total seconds by 1000 for delay time in miliseconds for ( int i = 9; i >0; i --) // countdown sequence before time lapse begins { sevenSegWrite(i); delay(1000); } clr(); // turns off all remaining lights } void loop() // main timelapse program { digitalWrite (Sht, HIGH); delay (1000); digitalWrite (Sht, LOW); delay (total); } void lad () // this function is my accept animation, feel free to edit to your personal preference { byte wait = 100; digitalWrite(5,1); delay (wait); digitalWrite(5,0); delay (wait); digitalWrite(7,1); delay (wait); digitalWrite(7,0); delay (wait); digitalWrite(9,1); delay (wait); digitalWrite(9,0); delay (wait); } void sevenSegWrite(byte digit) // input a integer value, output that number on the display { byte X = PIN; for (byte segCount = 0; segCount < 7; ++segCount) { digitalWrite(X, seven_seg_digits[digit][segCount]); ++X; } } void clr () // turns off any remaining lights that may be on { byte j = PIN; for (int count = 0; count < 7; count++) { digitalWrite(j,0); j ++; } } byte cycle() // retreives the value inputed by the user { int Bwait = 200; byte num = 0; //initial number to display sevenSegWrite(num); //display the number while (digitalRead(Ba) == LOW) // while the accept button is not pressed, loop the following code { if (digitalRead(Bc) == HIGH) // when cycle button is pressed, complete the following actions { num++; // increase the number by one if(num<10) // if the new value is less then 10... { sevenSegWrite(num); // display the increased value delay (Bwait); } else // if the new value is not less then 10... { num = 0; // set the value to 0 sevenSegWrite(num); // display 0 delay (Bwait); } } } // after the accept button has been pressed... clr(); // turn off display lad(); // show accept animation return num; // return the chosen value }