Sorry to address your specific point - YES - Arduino ALWAYS requires setup(), as I just discovered! If you were compiling directly into GCC, you could use main(), and ignore the Arduino overheads.
SETUP ONLY
Works fine...
bool toggle;
void setup() {
pinMode(13, OUTPUT);
while(1) {
toggle = !toggle;
digitalWrite(13, toggle);
delay(300);
}
}
LOOP ONLY
Oops! - I expected Arduino IDE would ignore the lack of a setup() function - just like it does for the lack of a loop()
bool toggle;
void setup(){ /* needed to satisfy the !Arduino! pre-processor*/ }
void loop() {
pinMode(13, OUTPUT);
while(1) {
toggle = !toggle;
digitalWrite(13, toggle);
delay(300);
}
}
Same for "Hello World" - or any other code you like
It's a bit odd the Arduino pre-compiler REQUIRES the setup(), but not the loop()