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);
// }
}