Serial monitor displaying junk.

I have Arduino duemilanove and it's 4-5 month old,
i have problem with serial interfacing,

i uploaded simple serial code:

void setup(){
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}
void loop(){
  Serial.println("abcdefghijklmnopqrstuvwxyz");
  digitalWrite(13,HIGH);
  delay(500);
  digitalWrite(13,LOW);
  delay(500);
}

led 13 is blinking but serial output is like "¸?®?ÅÄçGó".

so i tried another two atmega328 with Arduino boot-loader but same problem.
i also tried to uninstall drivers, restart pc, serial loopback test shorting 0 and 1, external serial monitor and everything is fine except serial monitor,
i also used putty but same output.

ps. i can still upload the sketch, pc baud rate 9600.

any ideas ???

By any chance is the serial monitor baudrate different than 9600? They need to be the same.

thanks for your replay but i mentioned that
PC BAUD RATE IS 9600".

Have you changed any of the processor clock speed settings?

nothing modified, just tried sd shield and it was working fine, but when i modified the sd sketch to read file and print on the serial the problem starts, don't know why. :expressionless:

thanks for your replay but i mentioned that
PC BAUD RATE IS 9600".

I realize you said that, it's just that I got some of the same characters you mentioned in your first post when I set my serial monitor to 300 baud. Hope you find a solution!

what does it do when you use a real serial terminal?

i also mentioned that i tried PUTTY and same output.

nothing modified, just tried sd shield and it was working fine, but when i modified the sd sketch to read file and print on the serial the problem starts, don't know why.

Well, right there - line 37 - that's where you went wrong.

If you were to actually post the code you are running, then perhaps one of us would be inclined to try to replicate your problem. Or spot it.

i just uploaded the example sketch, then i uploaded same code with different file names like test1.txt, user.txt, password.txt
and the last one was not working and hear's the code

#include <SD.h>

File myFile;

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
   pinMode(10, OUTPUT);
   
  if (!SD.begin(10)){
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("password.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to password.txt...");
    myFile.println("testing 1, 2, 3.");
	// close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening password.txt");
  }
}

void loop()
{
  myFile = SD.open("password.txt");
  if (myFile) {
    Serial.println("password.txt:");
    
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    	Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
  	// if the file didn't open, print an error:
    Serial.println("error opening password.txt");
  }
delay(1000);
}

so basically the last code didn't worked so i uploaded the serial test that i mentioned at the beginning.

thank you.

For anyone else experiencing garbage coming out of the serial port:

Are you using digital pins Rx 0 or Tx1??

These pins are used by the serial communications so your code might be injecting garbage!

The symptoms for this are:

  1. garbage appearing in the serial monitor
  2. whatever device you have connected to pins 0 and 1 is suffering from glitches.
    e.g. you get garbage on your serial port and garbage on your LCD (connected to pin 1)

Solution:
Connect your LCD (or whatever device you have connected) to some pins other than 0 Rx and 1 Tx

LindsayF:
For anyone else experiencing garbage coming out of the serial port:

Are you using digital pins Rx 0 or Tx1??

These pins are used by the serial communications so your code might be injecting garbage!

The symptoms for this are:

  1. garbage appearing in the serial monitor
  2. whatever device you have connected to pins 0 and 1 is suffering from glitches.
    e.g. you get garbage on your serial port and garbage on your LCD (connected to pin 1)

Solution:
Connect your LCD (or whatever device you have connected) to some pins other than 0 Rx and 1 Tx

This thread is 8 years old!