I have 2 Arduino Nano, they are connected via ports 2 and A2
While I use only one port to receive, it works properly. But if I activate the second port, system crash (and even first port don't work properly)
Code of first Arduino:
#include <SoftwareSerial.h> SoftwareSerial SerialPort2(2,A2); SoftwareSerial SerialPort3(3,A3); void setup() { SerialPort2.begin(9600); SerialPort3.begin(9600); Serial.begin(9600); } void loop() { delay(500); SerialPort2.listen(); if(SerialPort2.available()){ char value = SerialPort2.read(); Serial.print(value); Serial.print(" First port\n"); } // IF YOU REMOVE PART BELLOW, THE 'SerialPort2' WILL WORK PROPERLY SerialPort3.listen(); if(SerialPort3.available()){ char value = SerialPort3.read(); Serial.print(value); Serial.print(" Second port\n"); } // END OF THIS PART } Code of second Arduino:
#include <SoftwareSerial.h> SoftwareSerial SerialPort2(2,A2); void setup() { SerialPort2.begin(9600); } void loop() { SerialPort2.write('a'); delay(1000); } PS in real system I need to listen 6 ports