Problem with garbage character on serial port with Arduino UNO

Dear Arduino Master,

Please help me for a second. I am using Arduino UNO and I have a problem with serial output. I am using sketch Arduino 1.0 and Arduino 1.0.5. pin#0 and pin#1 are connected to a physical serial COM1 on a desktop PC. Pin#10 and pin#11 are connected to a physical serial COM2 on a desktop PC and it gave me bunch of garbage characters. If I am using Serial Monitor from sketch, I got my clear text. Simple coding as below:

====== begin of coding =====

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}

void loop() // run over and over
{
Serial.write(“Hello world 0-1 write\r\n”);
Serial.println(“Hello world 0-1 println”);
mySerial.write(“Hello world 10-11 write”);
mySerial.println(“Hello world 10-11 println\r\n”);
}

====== end of coding ====

But I did not get what I want on a physical serial COM1 on desktop PC. I capture the garbage output as below. I was using Putty COM1,9600,N-8-1.
ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿¥ú!¿¥¿

Also the same on a physical serial COM2 on a desktop PC. The same Putty setting COM2,9600,N-8,1
¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿¥¿

Did I made a wrong coding? What is the right coding for serial output? Please help me about it. I had tried to buy another Arduino UNO R3, but I got the same problem. I tried to use NewSoftSerial library, but it is not comparible with 1.0 and 1.0.5. I tried to use sketch 1.5.7 BETA version and it also give the same result as garbage character. After browsing site-to-site, I got no solution.

Regards,

Ronny

What do you mean this?

ronnyla:
(...)
pin#0 and pin#1 are connected to a physical serial COM1 on a desktop PC. Pin#10 and pin#11 are connected to a physical serial COM2 on a desktop PC
(...)

If you don't have any more hardware: "there is the problem"!

@Luisilva : Thanks a lot for your quick respon. I just want to use hardware serial from Arduino pin#0 and pin#1. But I was unable to make a good coding. I tried to write/post "hello word" from arduino and capture it in a desktop pc via serial COM1. But I got garbage character on my PC. Is any idea from you, Luisilva?

I tried to use SoftSerial (on pin#10&pin#11) also gave me garbage on my pc. I trie d to use NewSoftSerial library, but I got conflict on sketch arduino 1.0 and 1.0.5, even on 1.5.7 beta.

Yes, I have and I write my idea in the last reply.

How do you connect "pin#0 and pin#1" to the PC's "COM1"? What is the hardware/cables that you use? You are using a MAX232 or something like that, right?

@Luisilva,
No, I did not use any other component... just wire it from arduino to PC. I think this is the main problem. Do you have a schema for MAX232?

See this:

Yes you can not wire directly from those pins to a PC. The PC uses RS232 signals, they are -12V for mark and +12V for space. The Arduino uses TTL signals that are 5V for mark and 0V for space.
Putting -12V into an arduino will damage it. Luckily you made no mention of connecting the grounds together which might have saved you.

You need to connect the grounds but only when you have converted the voltage level and the logic sense of the signal. The MAX232 chip will do that for you:-

once you add the extra components.

@Luisilva : &
@Grumpy_Mike:

Thank you very much for the explainations about TTL-RS232-interfacing. Now I brain is opened. Btw I had connected the arduino UNO boards directly to serial COM desktop with jumper cable. I will double check and I hope the boards aren't burn/broken :fearful: :fearful:.

Another one question about the output from MAX232. Luisilva's drawing say that the VCC is +5V. How can it drive the RS232 signal requirement? As Grumpy_Mike said that the RS232 signal need -12V and +12Vdc.

Regards,

Ronny

The circuit inside the MAX 232 contains a voltage doubler and voltage inverter. This is done using diodes and capacitors running off an oscillator. It is quite a clever circuit, google
Diode voltage doubler
For a full circuit of this part.