user4869: I use simple LED blinking code on an Arduino MEGA 2560. I simulate it in Proteus. But pin number 9 doesn't power up. What is the problem?
My code:
// Set up the DATA direction
void setup()
{
  for(int i = 1; i<9; i++)
    pinMode (i, OUTPUT);
}

// The main program
void loop()
{
  for(int j=2; j<=10; j++)
  {
    digitalWrite(j, HIGH);
    delay(100);
    digitalWrite(j, LOW);
  }

  for(int j=9; j>=2; j--)
  {
    digitalWrite(j, HIGH);
    delay(100);
    digitalWrite(j, LOW);
  }
}

And the circuit is:


user42: It looks like your main problem is the loop in setup():
for(int i = 1; i<9; i++)
    pinMode (i, OUTPUT);

This will call pinMode() with values 1 to 8 (inclusive), and then stop. That means you aren't configuring pin 9 as an output. You need to change the loop condition to i<=9.
However, if your circuit diagram is accurate then you will have another problem. When implementing the circuit for real, you absolutely must have a suitable resistor in series with each LED (maybe something around 200 Ohms, depending on the exact specifications). If not, you seriously risk destroying the LEDs and maybe damaging your Arduino.

4869: <p>I use simple LED blinking code on an <a href="https://www.arduino.cc/en/Main/ArduinoBoardMega2560" rel="nofollow noreferrer">Arduino MEGA 2560</a>. I simulate it in Proteus. But pin number 9 doesn't power up. What is the problem?</p>

<p>My code:</p>

<pre><code>// Set up the DATA direction
void setup()
{
  for(int i = 1; i&lt;9; i++)
    pinMode (i, OUTPUT);
}

// The main program
void loop()
{
  for(int j=2; j&lt;=10; j++)
  {
    digitalWrite(j, HIGH);
    delay(100);
    digitalWrite(j, LOW);
  }

  for(int j=9; j&gt;=2; j--)
  {
    digitalWrite(j, HIGH);
    delay(100);
    digitalWrite(j, LOW);
  }
}
</code></pre>

<p>And the circuit is:</p>

<p><img src="https://i.stack.imgur.com/DeHzm.png" alt="Enter image description here"></p>
 42: <p>It looks like your main problem is the loop in <code>setup()</code>:</p>

<pre><code>for(int i = 1; i&lt;9; i++)
    pinMode (i, OUTPUT);
</code></pre>

<p>This will call <code>pinMode()</code> with values 1 to 8 (inclusive), and then stop. That means you aren't configuring pin 9 as an output. You need to change the loop condition to <strong><code>i&lt;=9</code></strong>.</p>

<p>However, if your circuit diagram is accurate then you will have another problem. When implementing the circuit for real, you absolutely <strong>must</strong> have a suitable resistor in series with each LED (maybe something around 200 Ohms, depending on the exact specifications). If not, you seriously risk destroying the LEDs and maybe damaging your Arduino.</p>
