Two serials can't work on the same speed I have a device which sits on pins 10/11 of Arduino UNO. I am trying to send commands from my PC using Arduino to relay my commands to the device via Serial. 

The problem is that if I use speed 9600 both for device and USB communication, then my commands gets damaged. Some letters are replaced by strange symbols, etc. The device uses 9600 baud rate. 

If I change speed of the PC communication to 4800 (or any speed other than 9600), everything is fine. But I have to use different speeds for the communication.

I am not comfortable with the workaround, because I don't understand what's going on. Could somebody explain why the same serial port speeds causes problems?

Here is my code:

#include &lt;SoftwareSerial.h&gt;

#define rxPin 11
#define txPin 10

SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

 void setup()
 {
   digitalWrite(4,HIGH); // 1 - disable
   mySerial.begin(9600);
   Serial.begin(19200);
   while (!Serial) {;}  // wait for serial port to connect. Needed for native USB port only
   Serial.println("Begin");
 }

 void loop()
 {
  if (mySerial.available()) 
  {
    char c = mySerial.read();
    Serial.write(c);  
  }
  if (Serial.available()) 
  {
    char c = Serial.read();
    mySerial.write(c); 
  }
 }
I spent some time playing with your code and it seems your code actually loops the serial therefore if they are both set at 9600 as example and you print what the other one is sending like in your code you end up in a loop if you want to read what your serial is sending it is better put that values in a variable and send it 

if you load your code you will get the following message in the arduino IDE once you try to connect to the serial monitor:

Error opening serial port 'COM8'. (Port busy),

your port is busy because the one serial port is reading the other all the time 

one more thing I would use the following if you want to repeat a serial port:


 
  if (mySerial.available()) 
  {
    //char c = mySerial.read();
    Serial.write(mySerial.read());  
  }


Hope this hels you