user40953: I've been trying to get a for loop to run 9 times using the below code but can't get the loop to run.
void output() {
  int r;
  r = 1;
  Serial.println("Output");
  digitalWrite(Latch, LOW);
  for (int r=1; r >= 9;  r = r + 1) {
    Serial.println("Test");
    digitalWrite(DataOutput, Q[r]);
    digitalWrite(ClockPin, HIGH);
    digitalWrite(ClockPin, LOW);
  }
  Serial.println("Done For");
  digitalWrite(Latch, HIGH);
  digitalWrite(Latch, LOW);
}


user14364: The middle expression r => 9 in the for loop is wrong. This will only loop whilst r is greater than 9 and you are starting from r = 1. Change it to r <= 9.

user2881: Change 
for (int r=1; r >= 9;  r = r + 1) {

to
for (int r=1; r <= 9;  r = r + 1) {

The for loop will only run while the second part is true.

40953: <p>I've been trying to get a for loop to run 9 times using the below code but can't get the loop to run.</p>

<pre><code>void output() {
  int r;
  r = 1;
  Serial.println("Output");
  digitalWrite(Latch, LOW);
  for (int r=1; r &gt;= 9;  r = r + 1) {
    Serial.println("Test");
    digitalWrite(DataOutput, Q[r]);
    digitalWrite(ClockPin, HIGH);
    digitalWrite(ClockPin, LOW);
  }
  Serial.println("Done For");
  digitalWrite(Latch, HIGH);
  digitalWrite(Latch, LOW);
}
</code></pre>
 14364: <p>The middle expression r => 9 in the for loop is wrong. This will only loop whilst r is greater than 9 and you are starting from r = 1. Change it to r &lt;= 9.</p>
 2881: <p>Change </p>

<pre><code>for (int r=1; r &gt;= 9;  r = r + 1) {
</code></pre>

<p>to</p>

<pre><code>for (int r=1; r &lt;= 9;  r = r + 1) {
</code></pre>

<p>The for loop will only run while the second part is true.</p>
