On an Arduino Uno, for loops behave very strangely when in an int function that doesn't return anything.
void setup() {
Serial.begin(9600);
}
void loop() {
foo();
Serial.println("Never reached");
}
int foo() {
for (int i = 0; i < 9; i++) {
Serial.println(i);
}
}
This outputs the following, and continues on indefinitely looping through ASCII...
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
Also, having the for condition as i < 12 makes it just count up numerically forever, none of the ASCII output.
This is all fixed by adding return 0; to foo(), but I'm curious why this happens. Any ideas?