combine two different codes to run simultaneously

Hi
I just got my first arduino uno and I wanted to start with an led project.
One part is a knight rider led array with 6 led’s and the other is just an led which fades (sketch).
I wanted to combine the two codes, so they can run simultaneously but after a lot of trial and error I still cant figure it out…
I would be really thankful if someone could do this for me or show me how.
here are the codes:

/* Knight Rider 3


  • This example concentrates on making the visuals fluid.
  • (cleft) 2005 K3, Malmo University
  • @author: David Cuartielles
  • @hardware: David Cuartielles, Aaron Hallborg
    */

int pinArray = {2, 3, 4, 5, 6, 7};
int count = 0;
int timer = 30;

void setup(){
for (count=0;count<6;count++) {
pinMode(pinArray[count], OUTPUT);
}
{
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
}

void loop() {
for (count=0;count<5;count++) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count + 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer2);
}
for (count=5;count>0;count–) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count - 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer
2);
}
{
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}


/*
Fade

This example shows how to fade an LED on pin 9 using the analogWrite()
function.

The analogWrite() function uses PWM, so if you want to change the pin you’re
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
are identified with a “~” sign, like ~3, ~5, ~6, ~9, ~10 and ~11.

This example code is in the public domain.

*/

int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

sorry for my bad enlgish

Simultaneously and delay() just do NOT go together. You need to rewrite both codes to use state machines and the blink without delay philosophy. Then, merging them will be trivial.

Create a new file or project, put the code that is in each of the loop() into a different function or method and then call the functions or methods from within the loop() of the newly created project.

Note: the created project should have only a single setup() and a single loop().

See the BlinkWithoutDelay.ino in examples/digital of the IDE, and understand it. If you don't fully understand, please come back here with your questions. State what you understand, and what you don't.

Translate both your codes so that they use that technique.

Do as Messach99 has suggested.