Oh yeah
Absolutely right PaulS.
Lets get the basics up and running first, here's a sketch that I did actually try out on my Arduino
int ledPin = 13; // LED connected to digital pin 13 You will need to change this.
int NumberOfPictures = 5; // How many pictures should we take?
int NumberOfPicturesTaken = 5; // I'll use this to keep a tab on how many pictures we've taken so far. I've set this to 5 already so nothings going to happen until its reset to 0
int ButtonPin = 3; // you'll need to change this.
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Start!");
pinMode(ledPin, OUTPUT);
pinMode(ButtonPin, INPUT_PULLUP);
}
void loop() {
if (digitalRead(ButtonPin) == LOW) NumberOfPicturesTaken = 0; // the magic line, if the button is pressed then the count is set to 0 so it all begins.
if (NumberOfPicturesTaken >= NumberOfPictures) return; // Stop now as NumberOfPicturesTaken indicates that we have taken the correct NumberOfPictures
NumberOfPicturesTaken ++;
Serial.print("NOPT = ");
Serial.println(NumberOfPicturesTaken);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
} // at this point it will go to the top of the loop at the void loop() line and start again.
// everything below this is nicely hidden away :)