我实际上正在使用FPVDrone 3DR无线电遥测连接我的笔记本电脑和arduino。我的连接是
ARDUINO tx- FPV Air module rx
ARDUINO rx- FPV Air module tx
ARDUINO 5v- FPV Air module 5v
ARDUINO GND- FPV Air module GND
而我的FPV接地模块连接到我的笔记本电脑。我有一个使用节点JS运行的应用程序,带有以下脚本
const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort('COM3');
port.write('hello');
我的arduino代码是
void setup() {
Serial.begin(57600);
}
void loop() {
if (Serial.available()) {
Serial.print((char) Serial.read());
delay(10);
}
}
我很确定他们在通信,因为我的arduino正在接收一些输出,然而输出是一些我不知道的字符,
arduino输出
有人能告诉我该怎么做吗?这样我就可以收到我的arduino的字符串"你好"了?
尝试在node.js脚本中设置baudrate
const port = new SerialPort(path, { baudRate: 57600 })
字符被搞砸是因为发送和接收的波特率不同。
确定发送到Arduino的字符是ASCII码吗?如果你发送的整数低于0x30,那么它们是不可打印的字符,你会看到胡言乱语。请确保发送ASCII符号或使用/制作可以显示原始整数的终端。