classic IR blaster game - some noob guidance

Hi all,

I'm new to working with programming and arduino having been involved with fighting robots for a long time. For my first project, I'm looking to make a simple IR blaster game based on the numerous tutorials you find online (double convex lens, high powered IR LED using some sort of transistor with matching receiver, etc). This wouldn't be laser tag - purely single shot from the rifle hitting a target which will either output noise, movements or both. The idea being that if I can get this basic system working, I can then expand it with further game functions.

Leading me onto my main question about the rifle code, all I want to do is when the trigger is depressed (and theoretically kept depressed indefinitely) is to illuminate the IR LED for given amount of time at a given frequency then deactivate and stay off until the trigger has been released. Essentially, a single shot process. At the same time as learning to write code, I'm beginning to theorise the structure of the code but whilst I can work out how to get the IR LED to pretty much flash, I can't get my head around how I'll get it to stay off after this if the trigger is held? Any help would be greatly appreciated.



Been bouncing ideas around in my head and is it as simple as having a loop basically doing the following? Or would I have to add an 'else' at the end to code to make it start again? I've used the button example to create the following.....

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

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

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

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 LED on:
digitalWrite(ledPin, HIGH);
delay(1000); // wait for a second
digitalWrite(ledPin, LOW);
if (buttonState == HIGH);
digitalWrite(ledPin, LOW);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);