Triggered LED blink and skipping a trigger event

hello -

i have some very simple code to run a TTL-triggered LED flash through an Arduino UNO. i have it working so that the LED blinks for a specified duration and after a specified delay following the TTL pulse. however, i would like to add an additional feature that would allow me to 'skip/ignore' certain triggers (e.g. only flash on every other trigger event or every 10th trigger, etc.).

brand new to arduino with very limited programming experience so i apologize for my ignorance in advance, but any help is much appreciated!

cheers,
jason

ps here is the code i am using (modified from previous code):

/*
TRIGGER - Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when receiving a TTL signal attached to pin 2. 
 
 The circuit:
 * LED attached from pin 13 to ground 
 * "trigger" attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 28 Oct 2010
 by Tom Igoe
 modified 1 May 2011
 by Jason Coleman

// constants won't change. They're used here to 
// set pin numbers:
const int triggerPin = 2;     // the number of the trigger pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int triggerState = 0;         // variable for reading the TTL status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(triggerPin, INPUT);     
}

void loop(){
  // read the state of the trigger value:
  triggerState = digitalRead(triggerPin);

  // check if the trigger is present.
  // if it is, the triggerState is HIGH:
  if (triggerState == HIGH) {     
    // turn LED on:
    delay(100);
    digitalWrite(ledPin, HIGH);  
    delay(50);
    digitalWrite(ledPin, LOW);  
  } 
//  else {
//    // turn LED off:
//    digitalWrite(ledPin, LOW); 
//  }
}

well, a simple, but perhaps effective for my case, is to just delay() the LED off in an else statement in the last bit since this blocks any subsequent trigger events... not perfect though, because i would like to trigger relative to an imaging 'frame', which will change depending upon the frame rate if i do it this way.

so, any help still much appreciated. thanks.

-jason

  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
    delay(3000); 
  }

Don't use delay(). It's a really bad function for all but the simplest sketches. Look at the blink without delay example to see how to time events without blocking the Arduino from doing anything else. You can also look at the Timer libraries in the Playground for tools that are useful for timing various events as well.

You should also look at both the Debounce and StateChangeDetection examples to see how to properly handle digital inputs. With that code, it would be trivial to increment a counter on an input transition (either the low to high transition, or high to low transition) and then perform some processing when the counter equals a certain value, or is within a certain range of values. This would not work properly with the way you are currently reading the input, as it would continuously increment the counter for as long as you held the button down.