viewing Serial.print output in GUI terminal

Hi

I have arduino 1.0.5 and am using an arduino based board called ArduPilot Mega (ATmega1280). I'm trying to just see some output in the terminal window. The compile and upload steps seem to operate with no complaints. Here's my code:

void setup()
{
  Serial.begin(38400);
}
void loop()
{
  Serial.print("Hello World");
  Serial.flush();
  delay(20);
}

In the terminal window is says:

Done Uploading
Binary sketch size: 3,830 bytes (of a 126,976 byte maximum)

I took some directions from:
http://code.google.com/p/ardupilot-mega/wiki/ProgrammingArduino

Any idea what I am missing?

Thanks...

I have the same problem. I do open the serial monitor, and get the new window, labled COM16 (I am using port 16).
My computer is running windows XP, and is a bit old. I thought my problem was in my XP, but have not verified it.
I have two arduino leonardo boards. Both load up and work well (except for serial print). Both will not serial print.
I added blink led on pin 13 to my test code. I notice when I open my serial monitor on my computer, the blinking slows down. When I close the serial monitor window, the led speeds back up. So sounds like it must be doing some kind of communication.

int led = 13;
void setup()                       // run once, when the sketch starts
{
  Serial.begin(9600);              // set up Serial library at 9600 bps
  pinMode(led, OUTPUT);  
}

void loop()                        // run over and over again
{
  Serial.println("Hello world!");  // prints hello with ending line break
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(200);               // wait for a second
}

My test code.

get the new window, labled COM16 (I am using port 16).

Folks, The Com window may be a DIFFERENT serial port number than the one you use to flash the Leonardo. Sometimes it returns to the same port number, sometimes Win will assign a new port number... on my installation, it is generally new.

After the download, the Windows PC will acquire a new port number for the Leonardo... after the download ends and the Leonardo reboots... this can take a few seconds depending on your Windows installation! On this dual-core 1.6 GHz with 4G Ram, it took almost 10 seconds.

Be patient. Use Device Manager to watch the screen repaint when the old port goes away and the new one appears. AFTER reset use the Tools/Serial_Port, then open the Serial Monitor.

References:
http://arduino.cc/en/Guide/ArduinoLeonardoMicro?from=Guide.ArduinoLeonardo
In part:

Serial re-enumeration on reset.
Since the boards do not have a dedicated chip to handle serial communication, it means that the serial port is virtual -- it's a software routine, both on your operating system, and on the board itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the Leonardo/Micro creates a serial instance whenever it runs its bootloader. The board is an instance of USB's Connected Device Class (CDC) driver.
This means that every time you reset the board, the USB serial connection will be broken and re-established. The board will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.

I checked (watched) the Device Manager. It refresh itself, but always uses com port 16.
I think if it did change to another port, I probably would not see the blinking led on pin 13 slow down, when I open the serial monitor. And then speed back up when I close the serial monitor window. What do you think?
BTW, I have tried two USB cables, and no help.
Wish I had another computer to try with, but I don't.

I probably would not see the blinking led on pin 13 slow down, when I open the serial monitor.

When the Serial Monitor is opened under the Arduino GUI, the sketch should restart. Perhaps you are seeing this as a change in LED blink rate.

On my WinVista installation, I am not seeing anything but a quick restart of the programmed software. What I found strange is that when I close the Serial Monitor, the Leo' freezes sometimes and the LED stops blinking.

Suggestion: Try another serial monitor program. I'm using Tera Term by T. Teranishi, logmett.com

Using Tera Term, I have absolutely no weird behavior, either opening or closing the terminal program.

The Leonardo has to wait for serial connection.

try putting this line in setup()

// while the serial stream is not open, do nothing:
   while (!Serial) ;

More info here http://arduino.cc/en/Guide/ArduinoLeonardoMicro?from=Guide.ArduinoLeonardo

I downloaded and tried Tera Term. That did not help.
I added leds on 2 other pins (7 and 9), to verify. When the blinking slowed down, it was not doing a reset, as led on pin 7 stayed on while 9 went off, and then the reversed, so the program was still running, just a lot slower. I set a delay(100) in the loop, and leds blinked at the speed I expected (about 10 times a second), When they slowed down, they blinked about ever 3 seconds. I can't explain that.

I tried adding while (!Serial) ;
and it did halt the code and wait, but when I opened the serial monitor, I still didn't get anything.

I am thinking it is a problem with the laptop/XP and the drivers. I have tried to reload the driver, but that didn't help either.

I am going to give up on this for now. I have been using a LCD for debugging, and it works pretty well.
Thanks for all your suggestions.

Delta_G:
Are you opening up the serial monitor? Last button all the way to the right on the IDE window.

Delta_G : that did it, thanks a bunch!!!