“Motion模块姿态测试示例”的版本间的差异
Radiumray9(讨论 | 贡献) |
Radiumray9(讨论 | 贡献) |
||
第46行: | 第46行: | ||
*打开'''文件'''->'''示例'''->'''_05_Microduino_10DOF'''->'''sensor_BMP085'''的“BMP085_basic”程序 | *打开'''文件'''->'''示例'''->'''_05_Microduino_10DOF'''->'''sensor_BMP085'''的“BMP085_basic”程序 | ||
[[File:motion-weather-bmp180.jpg|800px|thumb|center]] | [[File:motion-weather-bmp180.jpg|800px|thumb|center]] | ||
+ | |||
+ | <source lang="cpp"> | ||
+ | |||
+ | // 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(""); | ||
+ | |||
+ | } | ||
+ | </source> | ||
+ | |||
*将程序下载到核心,打开串口监视器,可以看到温度,气压,海拔数据。 | *将程序下载到核心,打开串口监视器,可以看到温度,气压,海拔数据。 | ||
[[File:motion-weather-res.jpg|800px|thumb|center]] | [[File:motion-weather-res.jpg|800px|thumb|center]] | ||
− | |||
− | |||
[[MCookie-Motion/zh|返回MCookie-Motion界面]] | [[MCookie-Motion/zh|返回MCookie-Motion界面]] |
2017年12月18日 (一) 07:23的最新版本
硬件清单
测试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("");
}
|