![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
HEPTA2 9軸センサー
Dependencies: Hepta2_9axis mbed
main.cpp@1:6ee85df13ebd, 2017-07-19 (annotated)
- Committer:
- hepta2ume
- Date:
- Wed Jul 19 08:16:35 2017 +0000
- Revision:
- 1:6ee85df13ebd
- Parent:
- 0:91fc70cdd15d
Hepta_9axis_sensor;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hepta2ume | 0:91fc70cdd15d | 1 | #include "mbed.h" |
hepta2ume | 1:6ee85df13ebd | 2 | #include"Hepta9axis.h" |
hepta2ume | 0:91fc70cdd15d | 3 | |
hepta2ume | 0:91fc70cdd15d | 4 | //DigitalOut myled(LED1); |
hepta2ume | 0:91fc70cdd15d | 5 | HeptaMPU9250 MPU9250(p28,p27,0xD0,0x18); |
hepta2ume | 0:91fc70cdd15d | 6 | Serial pc(USBTX,USBRX); |
hepta2ume | 0:91fc70cdd15d | 7 | int main() |
hepta2ume | 0:91fc70cdd15d | 8 | { |
hepta2ume | 0:91fc70cdd15d | 9 | while(1) { |
hepta2ume | 0:91fc70cdd15d | 10 | float ax,ay,az; |
hepta2ume | 0:91fc70cdd15d | 11 | float gx,gy,gz; |
hepta2ume | 0:91fc70cdd15d | 12 | float mx,my,mz; |
hepta2ume | 0:91fc70cdd15d | 13 | char gxa[4],gya[4],gza[4],axa[4],aya[4],aza[4],mxa[4],mya[4],mza[4]; |
hepta2ume | 0:91fc70cdd15d | 14 | int dsizea[4]; |
hepta2ume | 0:91fc70cdd15d | 15 | MPU9250.sen_acc(&ax,&ay,&az); |
hepta2ume | 0:91fc70cdd15d | 16 | MPU9250.sen_gyro(&gx,&gy,&gz); |
hepta2ume | 0:91fc70cdd15d | 17 | MPU9250.sen_mag(&mx,&my,&mz); |
hepta2ume | 0:91fc70cdd15d | 18 | MPU9250.sen_acc_u16(axa,aya,aza,&dsizea[0]); |
hepta2ume | 0:91fc70cdd15d | 19 | MPU9250.sen_gyro_u16(gxa,gya,gza,&dsizea[1]); |
hepta2ume | 0:91fc70cdd15d | 20 | MPU9250.sen_mag_u16(mxa,mya,mza,&dsizea[2]); |
hepta2ume | 0:91fc70cdd15d | 21 | pc.printf("AX = %f,AY = %f,AZ = %f\r\n",ax,ay,az); |
hepta2ume | 0:91fc70cdd15d | 22 | pc.printf("GX = %f,GY = %f,GZ = %f\r\n",gx,gy,gz); |
hepta2ume | 0:91fc70cdd15d | 23 | pc.printf("MX = %f,MY = %f,MZ = %f\r\n",mx,my,mz); |
hepta2ume | 0:91fc70cdd15d | 24 | |
hepta2ume | 0:91fc70cdd15d | 25 | pc.printf("AX_16 = "); |
hepta2ume | 0:91fc70cdd15d | 26 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 27 | pc.printf("%c",axa[i]); |
hepta2ume | 0:91fc70cdd15d | 28 | } |
hepta2ume | 0:91fc70cdd15d | 29 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 30 | pc.printf("AY_16 = "); |
hepta2ume | 0:91fc70cdd15d | 31 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 32 | pc.printf("%c",aya[i]); |
hepta2ume | 0:91fc70cdd15d | 33 | } |
hepta2ume | 0:91fc70cdd15d | 34 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 35 | pc.printf("AZ_16 = "); |
hepta2ume | 0:91fc70cdd15d | 36 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 37 | pc.printf("%c",aza[i]); |
hepta2ume | 0:91fc70cdd15d | 38 | } |
hepta2ume | 0:91fc70cdd15d | 39 | pc.printf("\r\n"); |
hepta2ume | 0:91fc70cdd15d | 40 | |
hepta2ume | 0:91fc70cdd15d | 41 | pc.printf("GX_16 = "); |
hepta2ume | 0:91fc70cdd15d | 42 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 43 | pc.printf("%c",gxa[i]); |
hepta2ume | 0:91fc70cdd15d | 44 | } |
hepta2ume | 0:91fc70cdd15d | 45 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 46 | pc.printf("GY_16 = "); |
hepta2ume | 0:91fc70cdd15d | 47 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 48 | pc.printf("%c",gya[i]); |
hepta2ume | 0:91fc70cdd15d | 49 | } |
hepta2ume | 0:91fc70cdd15d | 50 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 51 | pc.printf("GZ_16 = "); |
hepta2ume | 0:91fc70cdd15d | 52 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 53 | pc.printf("%c",gza[i]); |
hepta2ume | 0:91fc70cdd15d | 54 | } |
hepta2ume | 0:91fc70cdd15d | 55 | pc.printf("\r\n"); |
hepta2ume | 0:91fc70cdd15d | 56 | pc.printf("MX_16 = "); |
hepta2ume | 0:91fc70cdd15d | 57 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 58 | pc.printf("%c",mxa[i]); |
hepta2ume | 0:91fc70cdd15d | 59 | } |
hepta2ume | 0:91fc70cdd15d | 60 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 61 | pc.printf("MY_16 = "); |
hepta2ume | 0:91fc70cdd15d | 62 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 63 | pc.printf("%c",mya[i]); |
hepta2ume | 0:91fc70cdd15d | 64 | } |
hepta2ume | 0:91fc70cdd15d | 65 | pc.printf(","); |
hepta2ume | 0:91fc70cdd15d | 66 | pc.printf("MZ_16 = "); |
hepta2ume | 0:91fc70cdd15d | 67 | for(int i=0; i<4; i++) { |
hepta2ume | 0:91fc70cdd15d | 68 | pc.printf("%c",mza[i]); |
hepta2ume | 0:91fc70cdd15d | 69 | } |
hepta2ume | 0:91fc70cdd15d | 70 | pc.printf("\r\n"); |
hepta2ume | 0:91fc70cdd15d | 71 | |
hepta2ume | 0:91fc70cdd15d | 72 | } |
hepta2ume | 0:91fc70cdd15d | 73 | } |