Can anyone help me fading 6 leds?

I am building a lighthouse that has 6 leds. I want one led to fade to the next.
I found code to fade 3 leds from one to the next which works perfect for 3 leds. I added 3 more leds and they do not fade in sequence. They go 1,2,3 5,4,6 or such and do not fade in and out as the original three did.
The original code was to fade between three colors on a single led I think.
Each section I added to the original code is noted with a //=== explanation on what I did.
Can anyone help me out with this? I am new to "C" coding. The code is below:
Dave

const int FirstPin = 3;
const int SecondPin = 5;
const int ThirdPin = 6;
const int FourthPin = 9; // ==========Added outputs 9 to 11
const int FifthPin = 10;
const int SixthPin = 11;

// Brightness values
int first = 0;
int second = 0;
int third = 0;
int fourth = 0;//====Added three more here
int fifth = 0;
int sixth = 0;

int zone = 0; // Used to work out which LEDs should be on, off, or ramping up or down
int phase = 0; // Used to ramp brightnesses up or down (ranges between 0 - 255)
int fadeSpeed = 1; // amount phase is incremented by each update

void UpdateLedColours()
{
phase += fadeSpeed;

if(phase > 255)
{
phase = 0;
zone += 1;

if(zone > 11)// <==========Changed this from 5 to 11
{
zone = 0;
}
}

switch(zone)
{
case 0:
first = 255;
second = phase;
third = 0;
break;
case 1:
first = 255 - phase;
second = 255;
third = 0;
break;
case 2:
first = 0;
second = 255;
third = phase;
break;
case 3:
first = 0;
second = 255 - phase;
third = 255;
break;
case 4:
first = phase;
second = 0;
third = 255;
break;
case 5:
first = 255;
second = 0;
third = 255 - phase;
break;
//====================================== Added cases 6 to 11

case 6:
fourth = 255;
fifth = phase;
sixth = 0;
break;
case 7:
fourth = 255 - phase;
fifth = 255;
sixth = 0;
break;
case 8:
fourth = 0;
fifth = 255;
sixth = phase;
break;
case 9:
fourth = 0;
fifth = 255 - phase;
sixth = 255;
break;
case 10:
fourth = phase;
fifth = 0;
sixth = 255;
break;
case 11:
fourth = 255;
fifth = 0;
sixth = 255 - phase;
break;

}
}

void setup()
{
pinMode(FirstPin, OUTPUT);
pinMode(SecondPin, OUTPUT);
pinMode(ThirdPin, OUTPUT);
pinMode(FourthPin, OUTPUT);// added these three outputs
pinMode(FifthPin, OUTPUT);
pinMode(SixthPin, OUTPUT);
}

void loop()
{
UpdateLedColours();

analogWrite(FirstPin, first);
analogWrite(SecondPin, second);
analogWrite(ThirdPin, third);
analogWrite(FourthPin, fourth);//added these three pins
analogWrite(FifthPin, fifth);
analogWrite(SixthPin, sixth);

delay(4);
}

On each pass through loop(), UpdateLedColours() gets called. That function increments a variable, phase, by 1. When phase get to 256, it is reset to 0, and zone is incremented.

Your code additions look fine. If the LEDs don't behave as you want, simply swap the code in case n with the code in case m, until the zone actions look right.

PaulS,
First of all, thank you for your reply! I really do appreciate any help here.
Please bear with me. I am really new to programming "C" and don't know from your response about what you mean about swapping code from N to M.
I am sure more experianced programmers would know what you mean, but could you be a little more "specific" to someone who is new at this? Aain, I appreciate it.
Dave

You have code for case 6, and for case 7. If you think that case 7's code would look better after case 5's code has executed, move the case 7 to case 6, and the case 6 code to case 7.

PaulS,
I have tried that also but just seems like it makes things worse. Somehow the program does not follow onto the steps I added and the leds go off on some apparently intermittent tangent and I just cannot figger it out. I have been messing with this gor over a week and tried everything I can think of. I just cannot get the leds to follow the correct order after the thrid one.
Dave

Time for some debugging using Serial.print then. Display your major variables after you UpdateLedColours. A small delay in loop might help see what's happening too.

I believe your pattern to be this.
Adjust your code to have 6 writes in every case.

// the pattern - (off = 0, on = 255, up = phase (fading up), down = 255-phase (fading down)
// up, on, down
//LED 1 2 3 4 5 6
//1 up off off off off on case 1
//2 on off off off off down case 2
//3 on up off off off off
//4 down on off off off off
//5 off on up off off off
//6 off down on off off off
//7 off off on up off off
//8 off off down on off off
//9 off off off on up off
//10 off off off down on off
//11 off off off off on up
//12 off off off off down on
//1 up off off off off on and now repeats, but written here to see start of LED1, end of LED6
//2 on off off off off down

CrossRoads,
It took me a some time looking at your message to understand exactly what you were telling me as I don't have that much experiance with how "C" works yet. After I figured out your message, I saw the errors that I was missing as I didn't understand before how the cases were updating all the leds until you spelled it out. I corrected the code as you had told me. It works awsome! I really do appreciate your taking the time to "enlighten" me. And the time you expended to type up the corrections. I'm very grateful!
Dave

Glad to help.

Dave, please post corrected code. Thanks - Scotty

Scotty,
I put the pattern that CrossRoads figured out on a spreadsheet so I could see what was happening better (hey, I'm a newby :)).
It helped me understand the logic better. Maybe it will help you also.
Attached:
Dave

Lighthouse Leds High Lighted 1.xls (16 KB)