test
Diff: main.cpp
- Revision:
- 2:7d8b206eccbf
- Parent:
- 1:ffc27e62061d
--- a/main.cpp Wed Nov 06 07:18:14 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -#include "mbed.h" -#include "AE_KXSD9.h" -#include "SDFileSystem.h" -#define ADDR_W 0x30 -#define ADDR_R 0x31 - -Serial pc(USBTX, USBRX); // tx, rx -AE_KXSD9 i2c(D14, D15, ADDR_W, ADDR_R); //sda, scl, addr_w, addr_r -SDFileSystem sd(D11, D12, D13, D10, "sd"); -DigitalOut led(LED1); - -int Ready() { - - printf("Hello World!\n"); - printf("\nAnalogIn example\n"); - //mkdir("/sd/mydir", 0777); - - FILE *fp = fopen("/sd/mydir/AE_KXSD9.txt", "w"); - if(fp == NULL) { - error("Could not open file for write\n"); - } - } -int main() { - double x,y,z; - i2c.init(); - while(1){ - i2c.read_xyz(&x,&y,&z); - // pc.printf("\033[2J\033[0;0H");//clear console - pc.printf("x:%lf\r\ny:%lf\r\nz:%lf\r\n\n",x,y,z); - wait(1.0); - - fprintf(fp, "x y z \n"); - fclose(fp); - - //刻み時間 - //wait(1.0); // 1 second - } - }