Mega 2560 Serial Moniter

When I tried to make a code to help me make a rfid reader, I tested the serial monitor using this code:

void setup() {
  // put your setup code here, to run once:
  
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
 Serial.print(F("Hello World"));
 Serial.println();
 Serial.end();
 }

But in the serial monitor, it shows this: ⸮⸮⸮⸮⸮@⸮⸮⸮⸮⸮
Can you help me find out why?

You're disabling the Serial connection by calling end(), and then never enable it again. Also, is there any particular reason to write the string the flash (The F() )?

@TimMJN I purposely called end(), I added the (f()) because I needed it for the RFID reader code.

owen5600:
@TimMJN I purposely called end(), I added the (f()) because I needed it for the RFID reader code.

What was the intended purpose? It's not likely that it matches the outcome.

owen5600:
@TimMJN I purposely called end(), I added the (f()) because I needed it for the RFID reader code.

Well that hardly makes any sense. If you want to print just once, put the entire block in the setup()

On a final note, ensure that your Arduino and your serial monitor are set to the same baudrate

@TimMJN will do that.

Did what you both said but it still is doing the same thing.
Here is the code:

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.print("Hello World");
 }

void loop() {
  // put your main code here, to run repeatedly:

 }

what it says:⸮⸮⸮⸮⸮@⸮⸮⸮⸮⸮

Is your serial monitor baud rate set to 9600?

Yes. Could it be a defective Board?

owen5600:
Yes. Could it be a defective Board?

It's possible, but then I'd find it hard to believe uploading is working. Have you tried uploading Blink? Does that work as expected?

Yes, it does. It has worked for every code I upload to it, other than this one, which is it's first using the serial monitor.

Try connecting to it using a "real" terminal emulation program like Putty, or Tera Term.

Also, but a short delay after the Serial.begin

OK will do.

Just did that. (this has been going on for so long you probably think I am faking this, but I'm not)
I re-uploaded the code but now it is showing this error message when I try to upload:

avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected

For bad file descriptor, I would close serial monitor and the IDE and start the IDE again. If that doesn't solve the issue, reboot your PC.

Sounds like you disconnected the USB cable and later connected it again.

i just tried again but it is doing what it did in the begining.