Battery and SDcard

Dependencies:   mbed PowerControl SDFileSystem

Fork of HeptaBattery_SDFilesystem by 智也 大野

Revision:
0:50d269d8f117
Child:
1:39fee2519a16
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 09 04:52:08 2016 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "HeptaBattery.h"
+Serial pc(USBTX,USBRX);
+SDFileSystem sd(p11, p12, p13, p15, "sd");//ピンアサイン読み込み、オブジェクトの生成
+HeptaBattery battery(p16,p29,p26);
+
+int main() {
+    pc.baud(9600);
+    float bt;
+    char str[100];
+    pc.printf("Hello world!\r\n");
+    mkdir("/sd/mydir", 0777);
+    printf("helloworld\r\n");
+    FILE *fp = fopen("/sd/mydir/sdtest.txt","w");
+    if(fp == NULL) {
+        error("Could not open file for write\r\n");
+    }
+    for(int i=0;i<10;i++){
+        battery.vol(&bt);
+        fprintf(fp,"%f\r\n",bt);
+        wait(1.0);
+    }
+    fclose(fp);
+    fp = fopen("/sd/mydir/sdtest.txt","r");
+    for(int j=0;j<10;j++){
+        fgets(str,100,fp);
+        puts(str);
+    }
+    fclose(fp);
+    printf("Goodbye!!\r\n");    
+}
\ No newline at end of file