如何解决如何解决串行监视器上的无意义字符 Arduino
嗨,我是 Arduino Uno 的新手,我正在尝试使用 imu 传感器并从中读取数据,因此我从 arduino 网站安装了 mpu9500 库并从其库中运行了一个示例。但是,当我打开串行监视器时,它显示奇怪的字符。我多次检查引脚配置并加载不同的库和示例,但我无法修复它。 这是我运行的代码。
#include "MPU9250.h"
MPU9250 mpu;
void setup() {
Serial.begin(115200);
Wire.begin();
delay(2000);
if (!mpu.setup(0x68)) { // change to your own address
while (1) {
Serial.println("MPU connection failed. Please check your connection with `connection_check` example.");
delay(5000);
}
}
}
void loop() {
if (mpu.update()) {
static uint32_t prev_ms = millis();
if (millis() > prev_ms + 25) {
print_roll_pitch_yaw();
prev_ms = millis();
}
}
}
void print_roll_pitch_yaw() {
Serial.print("Yaw,Pitch,Roll: ");
Serial.print(mpu.getYaw(),2);
Serial.print(",");
Serial.print(mpu.getPitch(),");
Serial.println(mpu.getRoll(),2);
}
这就是我得到的,我也改变了 boud 的值,但没有任何改变
01:10:23.688 -> ⸮7в⸮⸮⸮⸮⸮⸮`f⸮⸮⸮⸮⸮f⸮⸮⸮~⸮⸮xxf⸮~⸮⸮fx⸮⸮⸮⸮⸮⸮怘⸮
解决方法
尝试以相同的波特率 (115200) 运行简单的串行打印代码并检查您的电路板是否正常。然后运行一次以下代码:
#include "MPU9250.h"
MPU9250 mpu; // You can also use MPU9255 as is
void setup() {
Serial.begin(115200);
Wire.begin();
delay(2000);
mpu.setup(0x68); // change to your own address
}
void loop() {
if (mpu.update()) {
Serial.print(mpu.getYaw()); Serial.print(",");
Serial.print(mpu.getPitch()); Serial.print(",");
Serial.println(mpu.getRoll());
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。