Battery and SDcard

Dependencies:   mbed PowerControl SDFileSystem

Fork of HeptaBattery_SDFilesystem by 智也 大野

Committer:
MEXT1
Date:
Tue Dec 13 10:51:59 2016 +0000
Revision:
2:43c8e1979d08
Parent:
1:39fee2519a16
Battery and SDcard

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomoya123 0:50d269d8f117 1 #include "mbed.h"
tomoya123 0:50d269d8f117 2 #include "SDFileSystem.h"
tomoya123 0:50d269d8f117 3 #include "HeptaBattery.h"
tomoya123 1:39fee2519a16 4
tomoya123 0:50d269d8f117 5 Serial pc(USBTX,USBRX);
tomoya123 1:39fee2519a16 6 SDFileSystem sd(p11, p12, p13, p15, "sd");
tomoya123 0:50d269d8f117 7 HeptaBattery battery(p16,p29,p26);
tomoya123 0:50d269d8f117 8
tomoya123 0:50d269d8f117 9 int main() {
tomoya123 0:50d269d8f117 10 pc.baud(9600);
tomoya123 0:50d269d8f117 11 float bt;
tomoya123 0:50d269d8f117 12 char str[100];
tomoya123 0:50d269d8f117 13 pc.printf("Hello world!\r\n");
tomoya123 0:50d269d8f117 14 mkdir("/sd/mydir", 0777);
tomoya123 0:50d269d8f117 15 printf("helloworld\r\n");
tomoya123 0:50d269d8f117 16 FILE *fp = fopen("/sd/mydir/sdtest.txt","w");
tomoya123 0:50d269d8f117 17 if(fp == NULL) {
tomoya123 0:50d269d8f117 18 error("Could not open file for write\r\n");
tomoya123 0:50d269d8f117 19 }
tomoya123 0:50d269d8f117 20 for(int i=0;i<10;i++){
tomoya123 0:50d269d8f117 21 battery.vol(&bt);
tomoya123 0:50d269d8f117 22 fprintf(fp,"%f\r\n",bt);
tomoya123 0:50d269d8f117 23 wait(1.0);
tomoya123 0:50d269d8f117 24 }
tomoya123 0:50d269d8f117 25 fclose(fp);
tomoya123 0:50d269d8f117 26 fp = fopen("/sd/mydir/sdtest.txt","r");
tomoya123 0:50d269d8f117 27 for(int j=0;j<10;j++){
tomoya123 0:50d269d8f117 28 fgets(str,100,fp);
tomoya123 0:50d269d8f117 29 puts(str);
tomoya123 0:50d269d8f117 30 }
tomoya123 0:50d269d8f117 31 fclose(fp);
tomoya123 0:50d269d8f117 32 printf("Goodbye!!\r\n");
tomoya123 0:50d269d8f117 33 }