Project 5 & 6 together

Hi!!!

I just recently got the Uno and am working my way though the book.I have successfully coded Projects 5 & 6 but was wondering what is the best way to link them both so they loop after each other.

So,far I have merged the codes but when I run it....they dont loop after one another but the 1st loop gets so far then the 2nd starts.Then the 1st finishes and restarts and the 2nd one comes in intermittently.It is very erratic.

So,basically I want to have a loop that runs the Chase Led sequence 1st fully,then the Bounce sequence fully and the Chase again and so on........

Here is as far as I have gotten with the code:

//Project LED Dance Floor
byte ledPin [] = {
  12,11,10,9,8}; //create an array for the led pins
byte ledPin2 [] = {
  4,5,6,7,8};
byte ledPinB [] = {
  4,5,6,7,8,9,10,11,12}; //creat an array for the led pins
int ledDelay(65); //delay between changes
int  x;
int  y;
int directionleft = 1;
int directionright = -1;
int currentLED1 = 0; //track left array
int currentLED2 = 0; //track right array
int direction = 1;
int currentLed =0;
unsigned long changeTime;
unsigned long changeTimeB;
int potPin = 2;    // select the input pin for the potentiometer  

void setup(){
  setupChase();
  setupBounce();
}

void loop(){
  loopChase();
  loopBounce();
}

void setupChase(){
  for (int x=0 ; x<5 ; x++){ 
    pinMode(ledPin[x], OUTPUT); //set all pins to output
    pinMode(ledPin2[x], OUTPUT);  
  }
  changeTime = millis();
}

void loopChase()
{
  ledDelay = analogRead(potPin); // read the value from the pot
  if ((millis() - changeTime) > ledDelay) { //if it has been ledDelay ms since last change
    changeLED();
    changeTime = millis();
  }
}
void changeLED(){
  for (int x=0;x<5;x++){ 
    digitalWrite(ledPin[x], LOW); //turn off all leds
    digitalWrite(ledPin2[x], LOW); //turn off all leds
  }

  digitalWrite(ledPin[currentLED1],HIGH); //turn on the current led
  digitalWrite(ledPin2[currentLED2],HIGH);
  currentLED1 += directionleft; //increment by the direction value
  currentLED2 -= directionright;

  if (currentLED1 ==4) {
    directionleft = -1;
  }
  //change direction if we reach the end
  if (currentLED1 ==0) {
    directionleft = 1;
  }

  if (currentLED2 ==4) {
    directionright = 1;
  }
  //change direction if we reach the end
  if (currentLED2 ==0) {
    directionright = -1;
  }

}

void setupBounce(){
  for (int y=0 ; y<9 ; y++){ 
    pinMode(ledPinB[y], OUTPUT); //set all pins to output
  }
  changeTimeB = millis();
}

void loopBounce()
{
  ledDelay = analogRead(potPin); // read the value from the pot
  if ((millis() - changeTimeB) > ledDelay) { //if it has been ledDelay ms since last change
    changeLEDB();
    changeTimeB = millis();
  }
}
void changeLEDB(){
  for (int y=0;y<9;y++){ 
    digitalWrite(ledPinB[y], LOW); //turn off all leds
  }

  digitalWrite(ledPinB[currentLed],HIGH); //turn on the current led
  currentLed += direction; //increment by the direction value

  if (currentLed ==8) {
    direction = -1;
  } //change direction if we reach the end
  if (currentLed ==0) {
    direction = 1;
  }
}

Any help would be greatly appreciated as I am newish to the world of MCU's!

Thanks in advance

Anybody any ideas???

See
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html