I'm trying to send ASCII characters from Arduino UNO to a computer serial port. I'm using a cable with a male COM connector, attached to the computer's serial port, and three wires (TX, RX and Ground) on the Arduino side. I used pins 12, 13 and Gnd as shown in the picture:
And I am running this piece of code to send a string every second on the serial port:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(13, 12); // RX, TX
void setup()
{
mySerial.begin(9600);
}
void loop()
{
mySerial.println("Hello world");
delay(1000);
}
But, when I read that port (at the right 9600 speed), instead of "Hello world" I get strange characters instead:
I thought I had set the pin erroneusly, so I swapped RX with TX, but I get a different but still wrong output:
What am I doing wrong?