![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
鈴木は下ネタ大好き
Dependencies: MPU6050 SDFileSystem mbed
佐藤健士郎は変態
Diff: main.cpp
- Revision:
- 0:7847f98921db
diff -r 000000000000 -r 7847f98921db main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 08 17:13:20 2018 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "SDFileSystem.h" +#include "MPU6050.h" + +SDFileSystem sd(dp2, dp1, dp6, dp4,"sd"); + +DigitalOut myled(LED1); +Serial pc(USBTX,USBRX); +MPU6050 mpu; +Timer t; + +int16_t ax, ay, az; +int16_t gx, gy, gz; + +char c; + +int main() { + + + pc.printf("MPU6050 test\n\n"); + pc.printf("MPU6050 initialize \n"); + + mpu.initialize(); + pc.printf("MPU6050 testConnection \n"); + + bool mpu6050TestResult = mpu.testConnection(); + if(mpu6050TestResult) { + pc.printf("MPU6050 test passed \n"); + } else { + pc.printf("MPU6050 test failed \n"); + } + t.start(); + + pc.printf("Hello World!\n"); + mkdir("/sd/ANBU!", 0777); + + while(1){ + FILE *fp = fopen("/sd/ANBU!/AUO.txt", "a"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + + wait(0.1); + mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); + //writing current accelerometer and gyro position + pc.printf("%f, %d, %d, %d, %d,%d, %d\n\r",t.read(),ax,ay,az,gx,gy,gz); + fprintf(fp,"%f, %d, %d, %d, %d,%d, %d\n\r",t.read(),ax,ay,az,gx,gy,gz); + + + fprintf(fp,"\n\r"); + pc.printf("\n\r"); + fclose(fp); + free(fp); + + } +}