我无法同时与四个Arduino通信。我用三个串口尝试了下面的代码,它工作正常。如果我添加第四个Arduino,则不会与任何Arduino进行通信 有人可以帮帮我吗?
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);
答案 0 :(得分:0)
似乎是硬件问题 - USB集线器往往会导致问题。我建议如下: