Can't understand why half of the pgm does not execute ! sorry !

I wrote a simple led lighting sequence, lighting going up the sequence then going down.
here is what I wrote:

int pinLedUp[5]={2,3,4,5,6};
int pinLedDown[5]={6,5,4,3,2};
int i;

void setup()

{
// put your setup code here, to run once: initialize pins as outputs, start at value 0
for (i = 0; i<5; i++)
pinMode(pinLedUp*, OUTPUT);*
pinMode(pinLedDown*, OUTPUT);*
digitalWrite(pinLedUp*, LOW);*
digitalWrite(pinLedDown*,LOW);*
}
void loop()
{
* //this loop to light leds one after the others in a rising sequence*
for (int i = 0; i<5; i++)
* {*
_ digitalWrite(pinLedUp*, HIGH);
delay(150);
digitalWrite(pinLedUp, LOW);
delay(150);
}
// then start this 2nd loop to light the same leds in a down going sequence*

* for (i=5; i==0; i–)*_

* {*
_ digitalWrite(pinLedDown*, HIGH);
delay(150);
digitalWrite(pinLedDown, LOW);
delay(150);
}
// repeat the loop*_

}
Result: the sequence lights up all right but doe not go down. it jumps the 2nd loop, I could not figure out why. I tried displaying on the condole the led values and variables, it all shows the same: the 2nd loop is never executed.
Why is that so ?
Thanks in advance !

You reverse the pin order in both the declaration

int pinLedUp[5]={2,3,4,5,6};
int pinLedDown[5]={6,5,4,3,2};

and the down loop ! This makes the down loop the same as the up loop.

Instead of:

for (i=5; i==0; i--)

Try:

for ( i = 5; i >= 0; i--)

And your for loops should look like:

for (int i = 0; i<5; i++)
     {
      digitalWrite(pinLedUp[i], HIGH);
      delay(150);
      digitalWrite(pinLedUp[i], LOW);
      delay(150);
     }

Good morning all
Stowite, thanks for the help, I do get some improvement, you were right. Now I have still to think and understand why I get small bugs (up 2,3,4,5,6, then 2 again and then the down going 6,5,4,3,2) in the order of lighting ! but I'll succeed. So again, thanks.

For Outsider, my loops seem rather same as what you advise, no change there.

Thanks to all, have a good day !

For Outsider, my loops seem rather same as what you advise, no change there.

Compare

for (i=5; i==0; i--)  //your for loop

with

 for (i = 5; i >= 0; i--)  //suggested for loop

Are they the same ?

Good morning Helibob

No of course, apparently. Apart from the spaces between parameters, I suppose my decreasing value loop will end going to i a value 'strictly equal' (==) to 0. While 'bigger or equal to 0' (>=) covers all values between 5 and 0, including 0. So should n't it bring the same result ? the loop in one case decrements from 5 to 0, while in the other case it decrements from 5 (beginning) until it is equal to 0.

Eager to learn because I tried all sorts of steps to get an answer. I tried to print on the console the values at each step, it just shows the loop stops before the decrementation.
SPent number of hours on it. Good for learning, which is my target, but there I don't know how to go further.

Thanks for the help !

The middle statement of a for loop means “while this is true” not “until this is true”
One way to understand a for loop is to think of it as a while loop instead.

for (int x = 0; x < 10; x++)
  {
     //execute this code
  }

is equivalent to

int x = 0;
while (x < 10)
{
  //execute this code
  x++;
}

Look at your for loop in this light and understand why it does not do what you want.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. Take a look at the code you posted, you’ll notice all the array subscripts on pinLedUp and pinLedDown are missing and most of your code is in italics. This wouldn’t have happened if you had used code tags. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Thanks a lot, Helibob, for your kind help and patience. I got it !
Of course it would not work.
I learned something this evening !

Sorry, Pert, I'll go and read the section you mention.

Thanks to all !