This is sample of "Lab3-04_save_battery_voltage_into_microsd_Q". If you haven't done it, you should do it before run this program. for textbook v4.4

Dependencies:   mbed HEPTA_EPS HEPTA_CDH

Files at this revision

API Documentation at this revision

Comitter:
HeptaSatTraining2019
Date:
Thu Aug 29 00:30:26 2019 +0000
Parent:
25:5fd40a170032
Commit message:

Changed in this revision

HEPTA_COM.lib Show diff for this revision Revisions of this file
HEPTA_SENSOR.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 5fd40a170032 -r cf0a3b2acb29 HEPTA_COM.lib
--- a/HEPTA_COM.lib	Tue Aug 27 01:15:05 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/HeptaSatTraining2019/code/HEPTA_COM/#1838cbd7d223
diff -r 5fd40a170032 -r cf0a3b2acb29 HEPTA_SENSOR.lib
--- a/HEPTA_SENSOR.lib	Tue Aug 27 01:15:05 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/HeptaSatTraining2019/code/HEPTA_SENSOR/#9023eea2a66e
diff -r 5fd40a170032 -r cf0a3b2acb29 main.cpp
--- a/main.cpp	Tue Aug 27 01:15:05 2019 +0000
+++ b/main.cpp	Thu Aug 29 00:30:26 2019 +0000
@@ -1,23 +1,32 @@
 #include "mbed.h"
 #include "HEPTA_EPS.h"
 #include "HEPTA_CDH.h"
-#include "HEPTA_SENSOR.h"
-#include "HEPTA_COM.h"
 
 Serial pc(USBTX,USBRX);
 HEPTA_EPS eps(p16,p26);
 HEPTA_CDH cdh(p5,p6,p7,p8,"sd");
-HEPTA_SENSOR sensor(p17, 
-                    p28,p27,0xD0,0x18,
-                    p13,p14,p25,p24);
-HEPTA_COM com(p9,p10);
-
-DigitalOut myled(LED1);
-
+ 
 int main()
 {
-    myled = 1;
-    wait(0.5);
-    myled = 0;
-    wait(0.5);
+    pc.baud(9600);
+    float bt;
+    char str[100];
+    mkdir("/sd/mydir", 0777);
+    FILE *fp = fopen("/sd/mydir/test.txt","w");
+    if(fp == NULL) {
+        error("Could not open file for write\r\n");
+    }
+    for(int i = 0; i < 10; i++) {
+        eps.vol(&bt);
+        fprintf(fp,"%f\r\n",bt);
+        wait(1.0);
+    }
+    fclose(fp);
+    fp = fopen("/sd/mydir/test.txt","r");
+    for(int j = 0; j < 10; j++) {
+        fgets(str,100,fp);
+        puts(str);
+    }
+    fclose(fp);
+    pc.printf("Goodbye!!\r\n");
 }
\ No newline at end of file