Battery and SDcard
Dependencies: mbed PowerControl SDFileSystem
Fork of HeptaBattery_SDFilesystem by
main.cpp
- Committer:
- tomoya123
- Date:
- 2016-12-13
- Revision:
- 1:39fee2519a16
- Parent:
- 0:50d269d8f117
File content as of revision 1:39fee2519a16:
#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"); }