Motion模块姿态测试示例
硬件清单
测试MPU6050姿态传感器
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz);
// display tab-separated accel/gyro x/y/z values
Serial.print("a/g:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);
}
测试BMP180气压传感器
// wait for available
while(!barometer.available());
// read calibrated temperature value in degrees Celsius
temperature = barometer.getTemperature();
// read calibrated pressure value in Pascals (Pa)
pressure = barometer.getPressure();
// calculate absolute altitude in meters based on known pressure
// (may pass a second "sea level pressure" parameter here,
// otherwise uses the standard value of 101325 Pa)
altitude = barometer.getAltitude();
// display measured values if appropriate
Serial.print("T/P/A\t");
Serial.print(temperature); Serial.print("\t");
Serial.print(pressure); Serial.print("\t");
Serial.print(altitude);
Serial.println("");
}
|