#include bool started = false; // rx_pin = 1; tx_pin = 2; rx is assigning input pin and tx assigns output pin SoftwareSerial Serial (1, 2); void setup() { Serial.begin(9600); //standard serial setup //must set high time out because parseInt only waits 1s for input. This allows us to enter input at our pace Serial.setTimeout(10000000); pinMode (4, OUTPUT); //mosfet_shutter = 3; //ATtiny45 PB3 pinMode (3, OUTPUT); //mosfet_focus = 4; //ATtiny45 PB4 Serial.println("Init"); } void loop() { /*command to say that if the program hasnt started, listen for input s, which then starts the rest of the code and we can input variables*/ if (!started){ if (Serial.read() == 's'){ started = true; } //once s has been recieved and program starts, we enter this part of the code } else { Serial.println("Enter Duration"); //enter an unsigned long in milliseconds. Needs a letter (or non-number) to know the end of the integer unsigned long duration = Serial.parseInt(); Serial.println(duration); Serial.println("Enter Interval"); //enter an unsigned long in milliseconds. Needs a letter (or non-number) to know the end of the integer unsigned long interval = Serial.parseInt(); Serial.println(interval); //putting runtime in terms of millis function which counts time passed since start of program unsigned long runtime = millis(); //while the runtime is < the duration we entered, go through the loop of writing high and low while (millis() - runtime <= duration){ digitalWrite (3, HIGH); //write shutter high (activates mosfet and shorts the circuit) delay(120); //short delay so that the interval can be .5 sec since 'interval' must be greater than delay digitalWrite (4, HIGH); //write focus high (activates mosfet and shorts the circuit) //put a delay between focus and shutter so that the camera has time to focus delay(120); //short delay so that the interval can be .5 sec digitalWrite (4, LOW); //digitalWrite (4, LOW); //write focus low (turns off mosfet) digitalWrite (3, LOW); //write shutter low //minus delay so time between photos is only the interval value we entered delay(interval-250); } } }