user15730: Are loops not allowed in setup()? The following doesn't print anything inside the for loop to the serial terminal
Code:
void setup() {
  Serial.begin(9600);
  Serial.println("Ping");
  for (int i = 0; i >= 10; i++) {
    Serial.println(i);
    Serial.println("Pong");
  }
}

void loop() {

}

Output:
Ping


user313: You could (and I occasionally do) write your entire program in the setup() function. Setup() and loop() are constructs provided for your convenience, but they aren't necessary. In C/C++ compiled programs, it conventional for the C run-time code to call main(), and for main() to be written by the programmer.
It is conventional within the Arduino IDE world to bury the complicated stuff to let new user get productive quickly with a gentle learning curve.
That includes a pre-written main() that provides the calls to setup() and loop() for you. 
The following main() function is typical of a number of pre-written Arduino main() functions, but you don't have to use the pre-written one; you can supply your own. It will need to call init(), and Arduino library function that prepares the hardware and software environment into a known state; after that you're good to go.
/*
 * main.cpp
 *
 *  Created on: Dec 13, 2011
 *      Author: jrobert
 */

#include "WProgram.h"

int main(void){
    init();
    setup();
    for(;;)
        loop();
}



extern "C" void __cxa_pure_virtual() {
    while (1)
        ;

}


user612: In principle yes, you can use a loop in setup() however this specific code 
for (int i = 0; i >= 10; i++) {
  Serial.println(i);
  Serial.println("Pong");
}

will result in the body of the loop never executing, as the loop test i >= 10 is initially false.
You probably meant i <= 10
Generally speaking, it would be poor program structure to use a loop in setup() in place of one in loop(), however if you need a loop to apply similar operations to a range of things, or to briefly busy wait on a condition as part of setting up operation, that kind of thing could be appropriate.

15730: <p>Are loops not allowed in setup()? The following doesn't print anything inside the <code>for</code> loop to the serial terminal</p>

<p><strong>Code:</strong></p>

<pre><code>void setup() {
  Serial.begin(9600);
  Serial.println("Ping");
  for (int i = 0; i &gt;= 10; i++) {
    Serial.println(i);
    Serial.println("Pong");
  }
}

void loop() {

}
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>Ping
</code></pre>
 313: <p>You could (and I occasionally do) write your entire program in the <code>setup()</code> function. <code>Setup()</code> and <code>loop()</code> are constructs provided for your convenience, but they aren't necessary. In C/C++ compiled programs, it conventional for the C run-time code to call <code>main()</code>, and for <code>main()</code> to be written by the programmer.</p>

<p>It is conventional within the Arduino IDE world to bury the complicated stuff to let new user get productive quickly with a gentle learning curve.
That includes a pre-written <code>main()</code> that provides the calls to <code>setup()</code> and <code>loop()</code> for you. </p>

<p>The following <code>main()</code> function is typical of a number of pre-written Arduino <code>main()</code> functions, but you don't have to use the pre-written one; you can supply your own. It will need to call <code>init()</code>, and Arduino library function that prepares the hardware and software environment into a known state; after that you're good to go.</p>

<pre><code>/*
 * main.cpp
 *
 *  Created on: Dec 13, 2011
 *      Author: jrobert
 */

#include "WProgram.h"

int main(void){
    init();
    setup();
    for(;;)
        loop();
}



extern "C" void __cxa_pure_virtual() {
    while (1)
        ;

}
</code></pre>
 612: <p>In principle yes, you can use a loop in setup() however this specific code </p>

<pre><code>for (int i = 0; i &gt;= 10; i++) {
  Serial.println(i);
  Serial.println("Pong");
}
</code></pre>

<p>will result in the body of the loop <em>never</em> executing, as the loop test <code>i &gt;= 10</code> is <em>initially</em> false.</p>

<p>You probably meant <code>i &lt;= 10</code></p>

<p>Generally speaking, it would be poor program structure to use a loop in setup() in place of one in loop(), however if you need a loop to apply similar operations to a range of things, or to briefly busy wait on a condition as part of setting up operation, that kind of thing could be appropriate.</p>
