I can't communicate to four Arduino's at the same time. I tried the code below with three serial ports and it worked fine. If I add a fourth Arduino, there is no communication with any Arduino.
Can somebody help me?
var SerialPort = require('serialport');
sport1 = new SerialPort('COM10', { autoOpen: true ,
parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport2 = new SerialPort('COM11', { autoOpen: true ,
parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport3 = new SerialPort('COM12', { autoOpen: true ,
parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport4 = new SerialPort('COM13', { autoOpen: true ,
parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
var u = 0;
setInterval(function() {
if(u==0) {
sport1.write("a");
sport2.write("b");
sport3.write("a");
sport4.write("b");
}else {
sport1.write("b");
sport2.write("a");
sport3.write("a");
sport4.write("b");
}
u = !u;
},500);