Battery and SDcard Q
Dependencies: mbed PowerControl SDFileSystem
Fork of HeptaBattery_SDFilesystem_Q by
main.cpp@1:6d9166677466, 2016-12-13 (annotated)
- Committer:
- tomoya123
- Date:
- Tue Dec 13 07:22:14 2016 +0000
- Revision:
- 1:6d9166677466
- Parent:
- 0:9eb94b338772
Battery and SDcard Q
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomoya123 | 0:9eb94b338772 | 1 | #include "mbed.h" |
tomoya123 | 0:9eb94b338772 | 2 | #include "SDFileSystem.h" |
tomoya123 | 0:9eb94b338772 | 3 | #include "HeptaBattery.h" |
tomoya123 | 1:6d9166677466 | 4 | |
tomoya123 | 1:6d9166677466 | 5 | Serial pc(USBTX,USBRX);//ピンアサイン読み込み、オブジェクトの生成 |
tomoya123 | 1:6d9166677466 | 6 | |
tomoya123 | 0:9eb94b338772 | 7 | |
tomoya123 | 0:9eb94b338772 | 8 | |
tomoya123 | 0:9eb94b338772 | 9 | int main() { |
tomoya123 | 0:9eb94b338772 | 10 | pc.baud(9600); |
tomoya123 | 0:9eb94b338772 | 11 | float bt; |
tomoya123 | 1:6d9166677466 | 12 | char str[100]; |
tomoya123 | 0:9eb94b338772 | 13 | pc.printf("Hello world!\r\n"); |
tomoya123 | 0:9eb94b338772 | 14 | mkdir("/sd/mydir", 0777); |
tomoya123 | 0:9eb94b338772 | 15 | printf("helloworld\r\n"); |
tomoya123 | 0:9eb94b338772 | 16 | FILE *fp = fopen("/sd/mydir/sdtest.txt","w"); |
tomoya123 | 0:9eb94b338772 | 17 | if(fp == NULL) { |
tomoya123 | 0:9eb94b338772 | 18 | error("Could not open file for write\r\n"); |
tomoya123 | 0:9eb94b338772 | 19 | } |
tomoya123 | 0:9eb94b338772 | 20 | for(int i=0;i<10;i++){ |
tomoya123 | 1:6d9166677466 | 21 | //バッテリー電圧を取得してsdtest.txtに書き込み |
tomoya123 | 0:9eb94b338772 | 22 | |
tomoya123 | 0:9eb94b338772 | 23 | |
tomoya123 | 1:6d9166677466 | 24 | } |
tomoya123 | 1:6d9166677466 | 25 | fclose(fp); |
tomoya123 | 1:6d9166677466 | 26 | fp = fopen("/sd/mydir/sdtest.txt","r"); |
tomoya123 | 1:6d9166677466 | 27 | for(int j=0;j<10;j++){ |
tomoya123 | 1:6d9166677466 | 28 | //バッテリー電圧を読みだしてPCに表示 |
tomoya123 | 0:9eb94b338772 | 29 | |
tomoya123 | 1:6d9166677466 | 30 | } |
tomoya123 | 0:9eb94b338772 | 31 | fclose(fp); |
tomoya123 | 0:9eb94b338772 | 32 | printf("Goodbye!!\r\n"); |
tomoya123 | 0:9eb94b338772 | 33 | } |