Motion模块姿态测试示例

来自Microduino Wikipedia
跳转至: 导航搜索


本示例给出了Motion获取姿态的一些基本方法



硬件清单



将Battery、Core、Motion模块堆叠在一起,通过MicroUSB数据线接入电脑。


测试MPU6050姿态传感器

  • 打开文件->示例->_05_Microduino_10DOF->sensor_MPU6050的“MPU6050_raw”程序
    // 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);

}
  • 将程序下载到核心,打开串口监视器,可以看到数据,前面三个对应的是X,Y,Z的角度,后三个对应的是X,Y,Z的加速度。


测试BMP180气压传感器

  • 打开文件->示例->_05_Microduino_10DOF->sensor_BMP085的“BMP085_basic”程序
    // 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("");

}
  • 将程序下载到核心,打开串口监视器,可以看到温度,气压,海拔数据。

返回MCookie-Motion界面

返回MCookie-Motion_Reference界面