Hi all, i am a complete nooby with programming and need some help.
what i am trying to do is fire a camera shutter from a inpulse from a electronic barrier, i have manage to get the camera to focus and fire the shutter with a button press but a can`t stop the camera from switching off after 10 mins.
so what i though i would do is put a delay of 9 mins in the loop when focus once when carry on, this seem to work apart from i have to wait a max of 9 mins before i can press the button again.
is there a way so the button press over rides the delay?
many thanks for your help
regards
Russ
/*
camera shutter
*/
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int focusPin = 7; // the number of the focus pin
const int shutterPin = 8; // the number of the shutter pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the focus pin as an output:
pinMode(focusPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// initialize the shutter pin as an input:
pinMode(shutterPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn focuspin on:
delay(10);
digitalWrite(focusPin, HIGH);
delay(1000);
digitalWrite(shutterPin, HIGH);
} else {
// to keep the camera from turning off:
digitalWrite(shutterPin, LOW);
digitalWrite(focusPin, LOW);
delay(540000); // max time i can keep the camera awake 9mins
digitalWrite(focusPin, HIGH);
delay(200);
digitalWrite(focusPin, LOW);
}
}