I'm using an Arduino Mega2560 connected to my PC via USB, and I'm seeing some odd behavior when I upload the following code using the Arduino IDE on Windows 11
That is normal. The Serial process needs a tiny amount of time to get ready. You will see many sample sketches use various techniques to deal with that. The most obvious is to add delay(1500); after the Serial.begin statement.
it is not normal. you must check what is connected to the PC/Mac and what program is started. not forget to check if it appear only in IDE, bc i seen such behavior never.
void setup() {
Serial.begin(9600);
Serial.println("\nABCDEFGHIJK");//will be always at new line
}
void loop() {}
If it wasn't normal why did the developers of the system make a function available to test for 'readiness'. Some boards just use delay, others use !Serial. Totally normal.