Serial.print WHY WON'T IT WORK

Here are the details: Board: Arduino Uno Rev.3, have tried two official "made in Italy" boards, and two clones. none work Computer: Gateway and HP, both with Windows 7, neither work. USB cable: Have tried two different cables, neither work. Sketch with Serial.print: Have downloaded three sketches off Arduino Examples site, and one I copied from Arduino for Dummies. none communicate serially. My sketches and wiring have to be correct, because the projects work perfectly other than writing to the computer's serial monitor. Occasionally I get a partial message, if I toggle the computer's serial monitor off and on. I can' be the only one to have had this problem. Any suggestions greatly appreciated. Thanks a million.

PeterRabbit: My sketches and wiring have to be correct

So, you have tried multiple hardware combinations, none of which work, and you still think your sketches and wiring have to be correct? I am afraid that I have to respectfully disagree.

The correct baud rate sounds like a great place to start...

Board: Arduino Uno Rev.3,

Did you install the comport driver for the Uno? In the IDE > Tools > Serial port do you see an available com port?

Thanks for the suggestion. I'm not sure what an IDE is. Each time I switch Arduino boards I need to go to tools and then to Com, to select the appropriate com. Is that what you mean by "Com driver"??? Please reply. Thanks.

Thanks so very much for your suggestions.

Yes, the baud rate is correct. That was one of the first things I checked.

About sketches: Three of the four sketches were downloaded directly form Arduino.cc examples and not modified. Please don't suggest that there is a problem with the sketches.

About wiring: All four of my applications work perfectly except for serial communications. They are very simple sketches and very simple wiring. If there was a problem with wiring the applications would not function properly.

What other ideas do you have? Thanks so very much.

You are not the only person to have this problem. You will probably only get it once. Turning the monitor off and on re-stets the programme. The IDE is essentially the window in which you write programmes, the one with black and turquoise stripes, and it tells you which COM port you are using at the bottom left corner. I think IDE stands for integrated development environment.

If you are using that, which is very likely, and you can upload a sketch OK by pressing the black arrow, there is nothing wrong with the programme, the USB cable, or the Arduino . So, do you see the message "Done Uploading" shortly after you press the black arrow?

Just stick with one Arduino board for the moment - it does wonders at reducing the confusion.

Check the "please read" and post your code. Just one, preferably not the one from the for Dummies book. On second thoughts, this should be all you need to prove your gear is kosher

void setup() {

  Serial.begin(9600);
  Serial.print("Hello");
  }

void loop() {
}

I'm going to suggest a slight difference from Nick's suggestion:

static const int heartbeat = 13;

void setup() {
  Serial.begin(9600);
  pinMode( heartbeat, OUTPUT );
  }

void loop() {
  digitalWrite( heartbeat, HIGH);
  Serial.println("Hello");
  digitalWrite( heartbeat, LOW);
  delay(1000);
}

I have changed Serial.print() to Serial.println() I have also moved it to loop() and added a 1000 msec delay. That way it will cause the message to repeat every second as long as the sketch runs. (Nick's sketch produces the desired output every time on my setup but I'm running Linux and not certain the behavior is the same on Windows.) You can also watch the TX and RX LEDs on the UNO. They will both flicker when you load the sketch and TX should flicker when your sketch writes to the serial port.

OK... Three changes. I added code to turn the output on pin 13 high during the serial write. I connect that to an LED in series with a 330 ohm resistor. I can see the LED light every time a serial write occurs. That gives me a very high level of confidence that the Serial.println() is being executed. Hopefully you have a spare digital output you can use for testing.

HTH, hank

Thank you so very much Nick and Hank; I'm relieved to learn that I'm not the only one who has had this problem.

Nick's test produced only one line of type every time I toggled the serial monitor off and on. But only twice out of ten times did it print a complete "Hello". Usually it was just "H", "He", or "Hel".

Hank's test did almost exactly the same. Once again, only one line of type every time I toggled the serial monitor off and on. The Tx LED, and LED hooked up to pin 13 flashed every second as expected.

What do you suggest next? Could it be that my USB driver is not installed properly?

Thanks so very much for your help.

Very simple serial test code. Copy and paste into the IDE code area. Upload via clicking the IDE upload arrow. When upload finished, open the serial monitor by clicking the serial monitor icon in the upper right of the IDE. Ensure 9600 baud rate is selected in the serial monitor. Type something in the serial monitor text box and send. What was typed in the text box should be sent back to the serial monitor display.

// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial test 0021"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    readString="";
  } 
}

And can you provide a screenshot showing the output in the Serial Monitor?

PeterRabbit: Nick's test produced only one line of type every time I toggled the serial monitor off and on. But only twice out of ten times did it print a complete "Hello". Usually it was just "H", "He", or "Hel".

I'm sure you understand that what I sent was the absolute minimum to prove the point - see something on the screen. The flashing lights are irrelevant at this stage. And yes, it is supposed to say one line - hello - in full, and nothing else.

If it says just "hel", there is there is something wrong, but the fact that it says something implies that it isn't serious - and no more money need be spent. I'm afraid I have no idea what it can be - other than to check in the bottom right corner of the serial monitor (again?) and ensure it says "no line ending" and "9600 baud".

I can't see how any driver can be the cause, but it costs nothing to re-install.....

Thanks a million Zoomkat.
Your sketch did not return the message which I sent.
However, every time I toggled off and on the serial monitor, a few of the first few letters of serial came up.
For example “Ser”

Someone asked to see a print-out of the screen.
I’ve attached it.
As you can see, the Baud as always, is 9600.

Lets please have some more ideas.
Thanks again.

Nick_Pyner: ensure it says "no line ending" and "9600 baud".

I see 9600 but I don't see "no line ending", I see "newline"

try changing it to "no line ending". I have no idea what these do, I'm just telling because that is what mine has.

Which version of arduino IDE software are you running? I have in the past encountered something similar with an older arduino IDE, possibly version 0019. I suspect that particular version arduino IDE opens serial port differently than other serial monitors.

Have you tried a different serial port program? I use this everyday:

https://sites.google.com/site/terminalbpp/

Several times you have said that you "toggle the computer's serial monitor off and on"

What exactly do you mean by that? Please describe all the activities that you do in connection with this.

With @HankB's sketch you should get a continuous output without toggling anything.

What version of the Arduino IDE are you using?

As someone else said, it would be a good idea to post a screen shot that shows the output you are getting.

...R

Thanks Robin for your interest. Yes, I have posted a screen shot. It confirms 9600 baud, and shows a typical partial transmission.

You ask how I "toggle the serial monitor off and on" I click on the serial monitor button at the upper right to turn on. I then click on the X at the upper right to turn off. Then I click on the serial monitor button again to turn back on. With each toggling of the screen I get a partial, but very rarely complete message. For example if the arduino was to transmit "Hello my friend", it would typically transmit "H", "He", or "Hell", and rarely "Hello".

I am using the current version of Ardurino. I downloaded it from adurion.cc just a few weeks ago.

What do you think? Thanks so very much.

(deleted)

I click on the serial monitor button at the upper right to turn on. I then click on the X at the upper right to turn off. Then I click on the serial monitor button again to turn back on. With each toggling of the screen I get a partial, but very rarely complete message.

Do you know that each time you toggle the serial monitor window the Arduino resets and so the program starts again? And that the serial buffer in the computer is not emptied when this happens, so yes you will get partial messages when you dick about with the serial monitor window.

This is a truly bizarre fault. Then again, computers do that.

OK, so it seems you have tried two completely parallel systems; two computers, two cables, at least two Arduino boards.

I’m with “liudr” - the only common things are Windoze 7 - of which I am not fond - and the IDE version. You should check which version you are using and ensure it it at least 1.0.

PROBLEM SOLVED I deleted Arduino software from both computers and reinstalled. Now serial.print works perfectly. Thanks for all your thoughtful suggestions.