Serial Monitor issue

Hi! My serial monitor appears to have an initialization time of about 2 seconds, after the serial.begin command. After some tests i realized that the board reads the code and works well, but the serial monitor only shows things that happen after the initialization time, which varies from time to time.
Is it normal?
How to fix it it? (besides putting a 2s delay in the setup function)
Thanks!
Alessandro

What does the Serial Monitor shown if you run this minimal test sketch:

byte x;
void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
}

void loop() {
  Serial.println(x++);
  delay(1000);
}

Funny, many users here had the opposite issue, because most examples use this trick.

Please note that when you use this, one day you will want to run your sketch without a Serial Monitor connected e.g., powering the board from a USB power bank. Remember then, if it does not work you probably forgot to disable/comment the while(!Serial) in your code.

Thank you guys!
I love you very much :smiley:
I did not know about the !serial command and now everything makes sense and works as i wished.
I guess I will encounter new and more difficult challenges in my adventurous path into this beautiful Arduino world.
I'll know where to come asking for help :wink:
Have a great one and stay safe!
Alessandro

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.