Help needed for Light Dependent Resistor - game

Hey, I'm doing a project in school where I will do a game where a LDR is needed to turn on and off some LEDs. Basically; When you put your hand over the LDR the value lowers, and I have made an if-statement and then a for-loop telling the LEDs to turn on when the LDR value is lower than the treashold. I want it to delay randomly between some seconds before the LEDs are turned on, that is all done. But my problem now is, when i remove my hand from the LDR it keeps delaying the same amout of time that the LEDs were turned on.

So, how can I make it so that when I take away my hand from the LDR the LEDs turns off again immediatley?

I use the Serial.begin(); and then i use the delay the intire serial monitor is delayed.

Here is my code:

[EDIT] Hey, I did what you told me to do, I hope it's better now.

int sens = 0;
int redPin[] = {2, 3};
int place = 2;
boolean set = HIGH;

void setup()
{
  Serial.begin(9600);

  for(int i = 0; i<place; i++)
  {
    pinMode(redPin[i], OUTPUT);
  }
}

void loop()
{
  int val = analogRead(sens);
  Serial.println(val);
  delay(450);

  if(val<240)
  {
    delay(random(1000, 5000));

    for(int i = 0; i<place; i++)
    {
      digitalWrite(redPin[i], set);
    }
  } 
  else
  {
    for(int i = 0; i<place; i++)
    {
      digitalWrite(redPin[i], !set);
    }
  }
}

You need to start now, learning how to post code. Look at what the forum showed us, and see if that matches your code. It doesn't, does it?

Modify your post. Select your code. Delete it. Press the code button (the one with the # in it). Then, copy your code again, and paste it between the tags that the code button inserts.

Before you paste your code again, though, clean it up. Put each { on a new line. Use Tools + Auto format to reformat your code.

Most likely, your problem is that you have an else block that is not associated with the correct if block, or you are not resetting some value correctly.

Without readable code to look at, though. it's all guesswork.