junvisitor 发表于 2017-3-27 21:48:39

arduino mega 2560 uart不能用

因为要用到多个串口,新买了几块arduino mega 的板子,连上蓝牙之后写了一段测试程序,发现用不了。

现在是一个蓝牙串口都用不了,只有连线是好用的。

有没有大神知道是怎么一回事?

还是说我买了假的板子?。。。

弘毅 发表于 2017-3-28 10:12:40

把代码发上来看看

junvisitor 发表于 2017-3-28 10:26:22

void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
}

// read from port 0, send to port 1:
if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
}
}

junvisitor 发表于 2017-3-28 10:27:25

junvisitor 发表于 2017-3-28 10:26


用的是官方的示例代码,我现在单独用RX TX都用不了:(

弘毅 发表于 2017-3-28 13:57:28

junvisitor 发表于 2017-3-28 10:27
用的是官方的示例代码,我现在单独用RX TX都用不了

看代码没啥问题。。。是2560用的,如果TX RX都不能用。。。那么板子可能就是坏的了。

junvisitor 发表于 2017-3-28 16:19:14

弘毅 发表于 2017-3-28 13:57
看代码没啥问题。。。是2560用的,如果TX RX都不能用。。。那么板子可能就是坏的了。

新买的板子。。还不止一块,是不是真的买到了假的板子。。:'(

弘毅 发表于 2017-3-28 16:31:06

junvisitor 发表于 2017-3-28 16:19
新买的板子。。还不止一块,是不是真的买到了假的板子。。

找个其他串口设备试试。。。或者你波特率不对。。所以获取不到数据。。。
页: [1]
查看完整版本: arduino mega 2560 uart不能用