![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
HEPTA2 9軸センサー
Dependencies: Hepta2_9axis mbed
Diff: main.cpp
- Revision:
- 0:91fc70cdd15d
- Child:
- 1:6ee85df13ebd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 19 07:35:07 2017 +0000 @@ -0,0 +1,73 @@ +#include "mbed.h" +#include"HeptaMPU9250.h" + +//DigitalOut myled(LED1); +HeptaMPU9250 MPU9250(p28,p27,0xD0,0x18); +Serial pc(USBTX,USBRX); +int main() +{ + while(1) { + float ax,ay,az; + float gx,gy,gz; + float mx,my,mz; + char gxa[4],gya[4],gza[4],axa[4],aya[4],aza[4],mxa[4],mya[4],mza[4]; + int dsizea[4]; + MPU9250.sen_acc(&ax,&ay,&az); + MPU9250.sen_gyro(&gx,&gy,&gz); + MPU9250.sen_mag(&mx,&my,&mz); + MPU9250.sen_acc_u16(axa,aya,aza,&dsizea[0]); + MPU9250.sen_gyro_u16(gxa,gya,gza,&dsizea[1]); + MPU9250.sen_mag_u16(mxa,mya,mza,&dsizea[2]); + pc.printf("AX = %f,AY = %f,AZ = %f\r\n",ax,ay,az); + pc.printf("GX = %f,GY = %f,GZ = %f\r\n",gx,gy,gz); + pc.printf("MX = %f,MY = %f,MZ = %f\r\n",mx,my,mz); + + pc.printf("AX_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",axa[i]); + } + pc.printf(","); + pc.printf("AY_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",aya[i]); + } + pc.printf(","); + pc.printf("AZ_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",aza[i]); + } + pc.printf("\r\n"); + + pc.printf("GX_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",gxa[i]); + } + pc.printf(","); + pc.printf("GY_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",gya[i]); + } + pc.printf(","); + pc.printf("GZ_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",gza[i]); + } + pc.printf("\r\n"); + pc.printf("MX_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",mxa[i]); + } + pc.printf(","); + pc.printf("MY_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",mya[i]); + } + pc.printf(","); + pc.printf("MZ_16 = "); + for(int i=0; i<4; i++) { + pc.printf("%c",mza[i]); + } + pc.printf("\r\n"); + + } +}