“Motion模块姿态测试示例”的版本间的差异
Radiumray9(讨论 | 贡献) (创建页面,内容为“{| style="width: 800px;" |- | <br> <big>本示例给出了Motion获取姿态的一些基本方法 <br> <br> <p style="color: #E87E05;font-size:135%">硬件清单</p…”) |
Radiumray9(讨论 | 贡献) |
||
(未显示同一用户的3个中间版本) | |||
第11行: | 第11行: | ||
*[[mCookie-Core]] | *[[mCookie-Core]] | ||
*[[MCookie-Motion/zh|MCookie-Motion]] | *[[MCookie-Motion/zh|MCookie-Motion]] | ||
− | |||
<br> | <br> | ||
<br> | <br> | ||
将Battery、Core、Motion模块堆叠在一起,通过MicroUSB数据线接入电脑。 | 将Battery、Core、Motion模块堆叠在一起,通过MicroUSB数据线接入电脑。 | ||
− | + | ||
<br> | <br> | ||
− | |||
− | |||
− | |||
− | |||
<p style="color: #E87E05;font-size:135%">测试MPU6050姿态传感器</p> | <p style="color: #E87E05;font-size:135%">测试MPU6050姿态传感器</p> | ||
*打开'''文件'''->'''示例'''->'''_05_Microduino_10DOF'''->'''sensor_MPU6050'''的“MPU6050_raw”程序 | *打开'''文件'''->'''示例'''->'''_05_Microduino_10DOF'''->'''sensor_MPU6050'''的“MPU6050_raw”程序 | ||
[[File:motion-weather-bmp180.jpg|800px|thumb|center]] | [[File:motion-weather-bmp180.jpg|800px|thumb|center]] | ||
− | |||
<source lang="cpp"> | <source lang="cpp"> | ||
− | Serial.print(ax | + | |
− | Serial.print(ay | + | // read raw accel/gyro measurements from device |
− | Serial.print(az | + | accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); |
− | Serial.print(gx | + | |
− | Serial.print(gy | + | // these methods (and a few others) are also available |
− | Serial.println(gz | + | //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); | ||
+ | |||
+ | } | ||
</source> | </source> | ||
*将程序下载到核心,打开串口监视器,可以看到数据,前面三个对应的是X,Y,Z的角度,后三个对应的是X,Y,Z的加速度。 | *将程序下载到核心,打开串口监视器,可以看到数据,前面三个对应的是X,Y,Z的角度,后三个对应的是X,Y,Z的加速度。 | ||
第40行: | 第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("");
}
|