user42740: I have a tutorial to finish and I don't know the code I have to use to make all (4 LEDs) to turn on in order. So this is my code and my simulation. Thanks in advance!

My Code: 
void setup() {
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  delay(100); // Wait for 100 millisecond(s)

  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  delay(100); // Wait for 100 millisecond(s)
}

EDITED:
I have to follow this one. I guess my simulator is correct.


user31105: Your code switches them all ON and OFF simultaneously.
What I read from your question is you want to turn them on in order.
In this case, use a simple state diagram. This means you have to create variable (preferably an enumeration), e.g.:
enum EState { FIRST_ON, SECOND_ON, THIRD_ON, FOURTH_ON };

EState _state;

You can better use better names than FIRST_ON, ..., but I do not know what your lights mean.
In the setup, you initialize _state, e.g.
_state = FIRST_ON;

Than in the loop you check and change the state:
switch (_state)
{
case FIRST_ON:
    digitalWrite(13, HIGH); // Assuming this is the first light
    digitalWrite(12, LOW); // Put the others off
    ...
    ...
    _state = SECOND_ON; // Set the next state
    break;

case SECOND_ON:
    digitalWrite(13, LOW); // Assuming this is the first light
    digitalWrite(12, HIGH); // Put the second LED on
    .. // Put the third/fourth off
    _state = THIRD_ON; // Set the next state
    break;

    // Do the same for THIRD_ON and FOURTH_ON

default: // in all other cases
     break; // Should not happen
}

delay(100: // Wait for 100 milliseconds

Note, to not complicate the example, I've written out (mostly) the lines like you:
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);

However, since these are almost copies (4 in the state diagram), it is best to write a separate function:
void SwitchLedsOn(int led1State, int led2State, int led3State, int led4State)
{
  digitalWrite(13, led1State);
  digitalWrite(12, led2State);
  digitalWrite(9, led3State);
  digitalWrite(6, led4State);
}

Now you can use in the first state case:
case FIRST_ON:
    SwitchLedsOn(HIGH, LOW, LOW, LOW); // Switch only first on
    break;

And do similar with the other states.

user37622: add this to loop() end
 digitalWrite(13, HIGH);
 delay(100);
 digitalWrite(12, HIGH);
 delay(100);
 digitalWrite(9, HIGH);
 delay(100);


user37523: I see in your second diagram that you are controlling the ground side of the LEDs. digitalWrite(PinNumber, HIGH) will turn an LED OFF, digitalWrite(PinNumber, LOW) will turn an LED ON. Using delay() in a sketch should be avoided.
void setup(){
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(6, OUTPUT); 
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
}

void loop(){
  digitalWrite(13, LOW);
  delay(100);
  digitalWrite(12, LOW);
  delay(100);
  digitalWrite(9, LOW);
  delay(100);
  digitalWrite(6, LOW);
  delay(100);
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  delay(100);
}


42740: <p>I have a tutorial to finish and I don't know the code I have to use to make all (4 LEDs) to turn on in order. So this is my code and my simulation. Thanks in advance!</p>

<p><a href="https://i.stack.imgur.com/3UGDd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3UGDd.jpg" alt="Figure 1"></a></p>

<p>My Code: </p>

<pre><code>void setup() {
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  delay(100); // Wait for 100 millisecond(s)

  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  delay(100); // Wait for 100 millisecond(s)
}
</code></pre>

<p>EDITED:
I have to follow this one. I guess my simulator is correct.</p>

<p><a href="https://i.stack.imgur.com/OIQmy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OIQmy.jpg" alt="Figure 2"></a></p>
 31105: <p>Your code switches them all ON and OFF simultaneously.</p>

<p>What I read from your question is you want to turn them on in order.
In this case, use a simple state diagram. This means you have to create variable (preferably an enumeration), e.g.:</p>

<pre><code>enum EState { FIRST_ON, SECOND_ON, THIRD_ON, FOURTH_ON };

EState _state;
</code></pre>

<p>You can better use better names than FIRST_ON, ..., but I do not know what your lights mean.</p>

<p>In the setup, you initialize _state, e.g.</p>

<pre><code>_state = FIRST_ON;
</code></pre>

<p>Than in the loop you check and change the state:</p>

<pre><code>switch (_state)
{
case FIRST_ON:
    digitalWrite(13, HIGH); // Assuming this is the first light
    digitalWrite(12, LOW); // Put the others off
    ...
    ...
    _state = SECOND_ON; // Set the next state
    break;

case SECOND_ON:
    digitalWrite(13, LOW); // Assuming this is the first light
    digitalWrite(12, HIGH); // Put the second LED on
    .. // Put the third/fourth off
    _state = THIRD_ON; // Set the next state
    break;

    // Do the same for THIRD_ON and FOURTH_ON

default: // in all other cases
     break; // Should not happen
}

delay(100: // Wait for 100 milliseconds
</code></pre>

<p>Note, to not complicate the example, I've written out (mostly) the lines like you:</p>

<pre><code>digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
</code></pre>

<p>However, since these are almost copies (4 in the state diagram), it is best to write a separate function:</p>

<pre><code>void SwitchLedsOn(int led1State, int led2State, int led3State, int led4State)
{
  digitalWrite(13, led1State);
  digitalWrite(12, led2State);
  digitalWrite(9, led3State);
  digitalWrite(6, led4State);
}
</code></pre>

<p>Now you can use in the first state case:</p>

<pre><code>case FIRST_ON:
    SwitchLedsOn(HIGH, LOW, LOW, LOW); // Switch only first on
    break;
</code></pre>

<p>And do similar with the other states.</p>
 37622: <p>add this to loop() end</p>

<pre><code> digitalWrite(13, HIGH);
 delay(100);
 digitalWrite(12, HIGH);
 delay(100);
 digitalWrite(9, HIGH);
 delay(100);
</code></pre>
 37523: <p>I see in your second diagram that you are controlling the ground side of the LEDs. digitalWrite(PinNumber, HIGH) will turn an LED OFF, digitalWrite(PinNumber, LOW) will turn an LED ON. Using delay() in a sketch should be avoided.</p>

<pre><code>void setup(){
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(6, OUTPUT); 
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
}

void loop(){
  digitalWrite(13, LOW);
  delay(100);
  digitalWrite(12, LOW);
  delay(100);
  digitalWrite(9, LOW);
  delay(100);
  digitalWrite(6, LOW);
  delay(100);
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  delay(100);
}
</code></pre>
