| 类别 | 项目 | 详细规格 |
|---|---|---|
| 基本信息 | 产品名称 | MPU6050 陀螺仪模块 |
| 通信方式 | I2C 通讯,最大 400KHz 速率 | |
| 接口类型 | PH2.0 4P 端子 | |
| 安装方式 | 螺丝固定 | |
| 电气参数 | 工作电压 | 3.3V~5V(直流 DC) |
| 陀螺仪运作电流 | 5mA | |
| 物理参数 | 模块尺寸 | 见附图 |
| 引脚定义 | GND | 电源负极 |
| VCC | 电源正极 | |
| SDA | I2C 数据引脚(SDA) | |
| SCL | I2C 时钟引脚(SCL) |

#include <Wire.h>
const int MPU_ADDR = 0x68;
int16_t AcX, AcY, AcZ, GyX, GyY, GyZ;
void setup() {
Serial.begin(9600);
Wire.begin();
// 唤醒MPU6050
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
}
void loop() {
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_ADDR, 14, true);
AcX = Wire.read() << 8 | Wire.read();
AcY = Wire.read() << 8 | Wire.read();
AcZ = Wire.read() << 8 | Wire.read();
GyX = Wire.read() << 8 | Wire.read();
GyY = Wire.read() << 8 | Wire.read();
GyZ = Wire.read() << 8 | Wire.read();
Serial.print("Accel: ");
Serial.print(AcX); Serial.print(" ");
Serial.print(AcY); Serial.print(" ");
Serial.print(AcZ); Serial.print(" | ");
Serial.print("Gyro: ");
Serial.print(GyX); Serial.print(" ");
Serial.print(GyY); Serial.print(" ");
Serial.println(GyZ);
delay(200);
}