Please help me out to combine these two codes!

(sorry for my bad English)

hello,
I’ve got two codes, one is a simple blink with delay , and another is Leap Motion
I want to combine these two codes and I hope it could work like this :
The blink code runs, and as Leap Motion detect hand, it turns to run my Leap Motion code,
BUT my blink code continues, my blink code looped every 3 minutes, and I had sound for it
so I don’t want when it turns to Leap Motion code it paused cause it will not match my sound after,

please help, thanks !

int val; 
long randomNumber;


int ledPin = 1;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin5 = 5;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;
int ledPin9 = 9;
int ledPin10 = 10;
int ledPin11 = 11;
int ledPin12 = 12;
int ledPin13 = 13;
int ledPin14 = 14;

int laser = 15;
int laser2 = 16;
int laser3 = 17;
int laser4 = 18;
int laser5 = 19;
int laser6 = 20;
int laser7 = 21;
int laser8 = 22;



void setup() {

  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(ledPin9, OUTPUT);
  pinMode(ledPin10, OUTPUT);
  pinMode(ledPin11, OUTPUT);
  pinMode(ledPin12, OUTPUT);
  pinMode(ledPin13, OUTPUT);
  pinMode(ledPin14, OUTPUT);

  pinMode(laser, OUTPUT);
  pinMode(laser2, OUTPUT);
  pinMode(laser3, OUTPUT);
  pinMode(laser4, OUTPUT);
  pinMode(laser5, OUTPUT);
  pinMode(laser6, OUTPUT);
  pinMode(laser7, OUTPUT);
  pinMode(laser8, OUTPUT);

  Serial.begin(9600); // Start serial communication at 9600 bps

}

void loop() {


  //LEAP PART
  randomNumber = random(2, 16);

  if (Serial.available())
  {
    val = Serial.read();
  }
  
  if (val != 0){
    
  
  if (val == 1)
  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
    digitalWrite(ledPin9, HIGH);
    digitalWrite(ledPin10, HIGH);
    digitalWrite(ledPin11, HIGH);
    digitalWrite(ledPin12, HIGH);
    digitalWrite(ledPin13, HIGH);
    digitalWrite(ledPin14, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin10, LOW);
    digitalWrite(ledPin11, LOW);
    digitalWrite(ledPin12, LOW);
    digitalWrite(ledPin13, LOW);
    digitalWrite(ledPin14, LOW);
    delay(1000);


  } else if (val == 2)
  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
    digitalWrite(ledPin9, HIGH);
    digitalWrite(ledPin10, HIGH);
    digitalWrite(ledPin11, HIGH);
    digitalWrite(ledPin12, HIGH);
    digitalWrite(ledPin13, HIGH);
    digitalWrite(ledPin14, HIGH);
    delay(700);
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin10, LOW);
    digitalWrite(ledPin11, LOW);
    digitalWrite(ledPin12, LOW);
    digitalWrite(ledPin13, LOW);
    digitalWrite(ledPin14, LOW);
    delay(700);
  } else if (val == 3)
  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
    digitalWrite(ledPin9, HIGH);
    digitalWrite(ledPin10, HIGH);
    digitalWrite(ledPin11, HIGH);
    digitalWrite(ledPin12, HIGH);
    digitalWrite(ledPin13, HIGH);
    digitalWrite(ledPin14, HIGH);
    delay(300);
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin10, LOW);
    digitalWrite(ledPin11, LOW);
    digitalWrite(ledPin12, LOW);
    digitalWrite(ledPin13, LOW);
    digitalWrite(ledPin14, LOW);
    delay(300);
  } else if (val == 4)
  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
    digitalWrite(ledPin9, HIGH);
    digitalWrite(ledPin10, HIGH);
    digitalWrite(ledPin11, HIGH);
    digitalWrite(ledPin12, HIGH);
    digitalWrite(ledPin13, HIGH);
    digitalWrite(ledPin14, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin10, LOW);
    digitalWrite(ledPin11, LOW);
    digitalWrite(ledPin12, LOW);
    digitalWrite(ledPin13, LOW);
    digitalWrite(ledPin14, LOW);
    delay(100);
  }





  else if (val == 5)
  { digitalWrite(randomNumber, HIGH);
    delay(1000);
    digitalWrite(randomNumber, LOW);
    delay(1000);
  } else if (val == 6)
  { digitalWrite(randomNumber, HIGH);
    delay(500);
    digitalWrite(randomNumber, LOW);
    delay(500);
  } else if (val == 7)
  { digitalWrite(randomNumber, HIGH);
    delay(300);
    digitalWrite(randomNumber, LOW);
    delay(300);
  } else if (val == 8)
  { digitalWrite(randomNumber, HIGH);
    delay(100);
    digitalWrite(randomNumber, LOW);
    delay(100);

  } else if (val == 9)
  {
    digitalWrite(ledPin8, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin10, LOW);
    digitalWrite(ledPin11, LOW);
    digitalWrite(ledPin12, LOW);
    digitalWrite(ledPin13, LOW);
    digitalWrite(ledPin14, LOW);
    delay(10);

  } else if (val == 10)
  {
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    delay(10);

  } 
  }

  
  if (val == 0){
  // laser part 01



  delay(15000);
  digitalWrite(laser, HIGH);
  delay(1500);
  digitalWrite(laser, LOW);
  delay(6500);
  digitalWrite(laser3, HIGH);
  delay(1500);
  digitalWrite(laser3, LOW);
  delay(6500);
  digitalWrite(laser5, HIGH);
  delay(1500);
  digitalWrite(laser5, LOW);
  delay(6500);
  digitalWrite(laser7, HIGH);
  delay(1500);
  digitalWrite(laser7, LOW);
  delay(3000);
  digitalWrite(laser2, HIGH);
  delay(700);
  digitalWrite(laser2, LOW);
  delay(3000);
  digitalWrite(laser4, HIGH);
  delay(700);
  digitalWrite(laser4, LOW);
  delay(3000);
  digitalWrite(laser6, HIGH);
  delay(700);
  digitalWrite(laser6, LOW);
  delay(3000);
  digitalWrite(laser8, HIGH);
  delay(700);
  digitalWrite(laser8, LOW);



  delay(34000);
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin2, HIGH);
  digitalWrite(ledPin3, HIGH);
  digitalWrite(ledPin4, HIGH);
  digitalWrite(ledPin5, HIGH);
  digitalWrite(ledPin6, HIGH);
  digitalWrite(ledPin7, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  digitalWrite(ledPin2, LOW);
  digitalWrite(ledPin3, LOW);
  digitalWrite(ledPin4, LOW);
  digitalWrite(ledPin5, LOW);
  digitalWrite(ledPin6, LOW);
  digitalWrite(ledPin7, LOW);
  delay(500);

  digitalWrite(laser, HIGH);
  delay(500);
  digitalWrite(laser, LOW);

}

ATBLEAPTEST02.ino (22 KB)

You'll never get those two codes to work together until you get rid of ALL of the delay()s in the LED code.

Arrays would be hugely useful, too.

int ledPin = 1;
int ledPin2 = 2;

I guess you started with one LED with no number suffix then added the others. At best it looks untidy, but why not use an array in the first place ?

Using pin 1 may not also be a good idea either if you plan on using the Serial interface.