need help regarding communication between two boards

Hello everyone,

I just want to sand some RS485 string serial from a master board and receive it by a slave board. I bought two shields from linksprite and did the same as the tutorial said with two Mega boards. (http://learn.linksprite.com/arduino/shields/tuotorial-of-using-rs485-shield-v2-on-arduino/)

However, my slave board just gave me no response, so I changed the slave code as following.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3,2);
void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() {
  if(mySerial.available() > 0)
  {Serial.write("abc\n");
delay(1000);}
  else
  {
    Serial.write ("123\n");
    mySerial.print ("123");
    delay(1000);
  }
}

The result shows “123” all the time, which I think means there is no data has been written in the buffer zone.

Any suggestion about what I have done wrong?

Thanks a lot

Regards

Hi, welcome to the forum.

Two Mega boards ? Read this : https://www.arduino.cc/en/Reference/SoftwareSerial It says: "Not all pins on the Mega and Mega 2560 support change interrupts...".

:o :o :o thanks very much,

So, will change one of them into Uno work?

Only the RX needs such a special pin. If both Arduino boards receive data, it will work when both are Uno boards. If only one board is using the Software Serial RX, then you can exchange that board with an Uno.

I would solder a wire, so one of the allowed pins of the Mega board would be used.

Many thanks again Peter

Why use Software Serial if you have a Mega? It has 4 Hardware Serial ports.

...R

thanks for the reply...I was just following the example.

Also, connect two boards is not my final goal.

Anyway, I will take some time to think about it for sure. Thank you