How to keep reading a sensor until the delay is over (arduino uno laser sensor)

Here's what I'm trying to accomplish on my small scale demo. I have 3 laser sensors and 3 LEDs. Each LED cooresponds to a laser sensor. The idea is that the program picks a random laser sensor (0,1,2),lights up its cooresponding LED and checks the laser sensor for a laser that hits it. If it is hit with a laser, it lights up a 4th LED to let you know the sensor was hit.

Right now, it works as long as the laser is hitting the sensor the moment its number is called, but it does not continue to "poll" the sensor for the duration of the delay. I'm not sure if I need a loop inside of a loop (which sounds like a bad idea), or I need to use something other than delay in order to stop the loop from exiting.

Sorry for the NOOB question. I'm a php guy and I'm having a problem wrapping my mind around this. My sense is that

boolean val1 = digitalRead(pinMatrix[randNumber][0]);

is only being called once in the loop.

Here's my complete code for context.

long randNumber;
long delayTime;
int hit;
int pinMatrix[3][2] = {

  {2,  13 },

  {3,  8 },

  {4,  9  }

char one[] = "hit";

void setup() {
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  pinMode(3, INPUT);
  pinMode(8, OUTPUT);
  pinMode(4, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // if analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.

void loop() {
  // print a random number from 0 to 2
  randNumber = random(3);
  delayTime = random(2000, 5000);
  digitalWrite(pinMatrix[randNumber][1], HIGH);

  hit = 0;
  digitalWrite(10, LOW);
  if (hit < 1) {
    boolean val1 = digitalRead(pinMatrix[randNumber][0]);
    if (val1 > 0) {
      digitalWrite(pinMatrix[randNumber][1], LOW);
      hit = 1;
      digitalWrite(10, HIGH);
  digitalWrite(pinMatrix[randNumber][1], LOW);

Get rid of delays. Note the time u get a 'hit' in a variable. ( eg. hit1=millis(); )
You can check time since hit (millis()-hit1) to do the nest required action.

I like that idea, but if a person misses a target over and over, how would I allow them to go onto the next one?

There is no hardware to detect a miss, but you can check all targets for a hit.
..May be an idea to use interrupt control for this task.

I guess I'm still trying to figure out, is there a way to keep checking that one sensor for a hit for a limited amount of time and then go on in the loop. Like, is there a way to loop for a particular amount of time instead of delaying and doing nothing.

Lookup the sketch called blinkwithoutdelay that is under digital examples when you download Arduino.

Not real code and not the prettiest, but this is how I would go about approaching the problem.

unsigned long previousTargetCheck = 0;//The time when the clock started running
const long intervalToNextTarget = 1000; //How long we have to hit the target.

bool hitIt = false;

void setup() {
  // put your setup code here, to run once:


void loop() {
  testhit();//This needs to happen often, so keep as much stuff out of the loop as possible.
  if (hitIt == ture) {
    //You hit it!!
  unsigned long currentMillis = millis();//Get the time
  if (currentMillis - previousTargetCheck >= intervalToNextTarget) {//Ran out of time to hit the target
    if (hitIt == ture) {//Probably not needed, but this may be what you have in mind instead of the (hitIt==true) test above
      //You hit it!!
    else {
      //ran out of time and have not hit the target
  }//time loop

void testhit(void) {
  //Code to check if the target has been hit.
  //You will have to figure this bit out with your sensors ect.
  //If it hits something set hitIt to true.
  hitIt = true;
  //If nothing was hit do nothing, just leave function.

void hitItDoSomething(void) {
  //Code for when a target is hit.
  previousTargetCheck = millis(); //Reset the clock for the next target.

void missed() {
  //Code for when they have run out of time and not hit the target yet.
  //Select a new target to shoot ect.