I tried to replicate your problem. I found something interesting. If you sometimes use a dual monitor setup, and put the Serial Monitor on the second monitor, there is no way to move it if you do not have that second monitor attached. I use two monitors at work, but only one at home. The last time I opened the Serial Monitor, I moved it to the other monitor. Now, I can not move it back, or see it. Hard to see how often the statement is printed to the serial monitor when you can not see the serial monitor.
niorf:
Do you have any idea why this function always returns 0 ?
Make sure you call init(). This sets up the timer that the counter runs off. e.g. to imitate the Arduino IDE:
#include <wiring.h> // from the Arduino library
int main(int argc,char **argv) {
init();
setup();
for(;;)
loop();
return 0; // not reached
}
PaulS:
I tried to replicate your problem. I found something interesting. If you sometimes use a dual monitor setup, and put the Serial Monitor on the second monitor, there is no way to move it if you do not have that second monitor attached. I use two monitors at work, but only one at home. The last time I opened the Serial Monitor, I moved it to the other monitor. Now, I can not move it back, or see it.
Assuming you're on Windows...
Select the serial monitor in the task bar. It will come to the foreground on the invisible monitor.
Press Alt-Space to drop down the system menu.
Press M to start moving it.
Use the cursor arrows to move it back to the primary monitor. Actually after you've pressed any cursor at least once you can then use the mouse to swing it back into view.
NB. If you have it maximised on the invisible monitor you'll need to do Alt-Space, R to restore it before moving it.
I didn't call init() !!
Now I got another issue: the opposite of the first one
The following code don't wait 2 seconds to print "OK".
=> the delay function does not block...
int main() {
init();
Serial.begin(115200);
while (true) {
Serial.println("OK");
delay(2000);
}
}