Nuleo F303K8とMPU6050を用いた3軸加速度検出における処理時間の計測

Dependencies:   MPU6050 mbed

Fork of Time_MPU6050_Acceleration3 by Ryota Nakamura

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "MPU6050.h"
00004 #define acc 16384
00005 
00006 DigitalOut myled(LED1);
00007 MPU6050 mpu(D4,D5);
00008 Serial pc(USBTX, USBRX);
00009 Timer timer;
00010 
00011 int main(){
00012     float a[3];
00013     int miri=1000;
00014     mpu.setAcceleroRange(0);
00015     
00016     while(1) {
00017         wait(1);
00018         
00019         myled = 1;
00020         wait(0.2);
00021         myled = 0;
00022         wait(0.2);
00023 
00024         timer.reset();
00025         timer.start();
00026         mpu.getAccelero(a);
00027         timer.stop();
00028         float t=timer.read();
00029         float time=t*miri;
00030         pc.printf("time= %f ms\n",time);
00031     }
00032 }