So I have two Arduinos (Arduino Nano) and I'm trying to get them to communicate via SoftwareSerial. I have the 'sending' Arduino's D10 pin connected to the 'recieving' Arduino's D11 pin, and vice versa. On my sending Arduino, I have the following code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
void setup() {
pinMode(2, OUTPUT);
mySerial.begin(9600);
}
void loop() {
if (mySerial.isListening()){
digitalWrite(2, HIGH);
}
mySerial.write(5);
}
and on my receiving Arduino, I have:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10);
void setup() {
pinMode(2, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
mySerial.listen();
if (mySerial.available()>0) {
digitalWrite(2, HIGH);
char inByte = mySerial.read();
Serial.write(inByte);
}
digitalWrite(2, LOW);
}
(with D2 being hooked up to an LED for both).
I can't get it to read anything. Nothing seems to be available for the receiving Arduino (the LED is off). What am I doing wrong?