Pengujian Battery
Dependencies: SDFileSystem TextLCD mbed
Fork of Seeed_SDCard_Shield by
main.cpp@0:525c842a3c89, 2014-03-17 (annotated)
- Committer:
- screamer
- Date:
- Mon Mar 17 15:45:16 2014 +0000
- Revision:
- 0:525c842a3c89
- Child:
- 1:93d41c73ac7d
Initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:525c842a3c89 | 1 | #include "mbed.h" |
screamer | 0:525c842a3c89 | 2 | #include "SDFileSystem.h" |
screamer | 0:525c842a3c89 | 3 | #include "bdebug.h" |
screamer | 0:525c842a3c89 | 4 | |
screamer | 0:525c842a3c89 | 5 | SDFileSystem sd(D11, D12, D13, D10, "sd"); // MOSI, MISO, SCK, CS |
screamer | 0:525c842a3c89 | 6 | DigitalOut led1(LED1); |
screamer | 0:525c842a3c89 | 7 | DigitalOut led2(LED2); |
screamer | 0:525c842a3c89 | 8 | FILE *fp; |
screamer | 0:525c842a3c89 | 9 | |
screamer | 0:525c842a3c89 | 10 | int main() { |
screamer | 0:525c842a3c89 | 11 | blink(led1, 1, 1); |
screamer | 0:525c842a3c89 | 12 | |
screamer | 0:525c842a3c89 | 13 | fp = fopen("/sd/hello.txt", "r"); |
screamer | 0:525c842a3c89 | 14 | if (fp != NULL) { |
screamer | 0:525c842a3c89 | 15 | fclose(fp); |
screamer | 0:525c842a3c89 | 16 | remove("/sd/hello.txt"); |
screamer | 0:525c842a3c89 | 17 | } |
screamer | 0:525c842a3c89 | 18 | |
screamer | 0:525c842a3c89 | 19 | fp = fopen("/sd/hello.txt", "w"); |
screamer | 0:525c842a3c89 | 20 | if (fp == NULL) { |
screamer | 0:525c842a3c89 | 21 | blink(led2, 2); |
screamer | 0:525c842a3c89 | 22 | } else { |
screamer | 0:525c842a3c89 | 23 | blink(led1, 20, 0.05); |
screamer | 0:525c842a3c89 | 24 | led1 = 1; |
screamer | 0:525c842a3c89 | 25 | fprintf(fp, "mbed SDCard application!"); |
screamer | 0:525c842a3c89 | 26 | fclose(fp); |
screamer | 0:525c842a3c89 | 27 | } |
screamer | 0:525c842a3c89 | 28 | |
screamer | 0:525c842a3c89 | 29 | blink(led2, 1, 10); |
screamer | 0:525c842a3c89 | 30 | } |