SD File System Hello World

Dependencies:   SDFileSystem mbed

Dependents:   SDFileSystem SDFileSystemv2 SDFileSystem_HelloWorld GEO_SHOW2ME_F411RE ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003  
00004 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
00005  
00006 int main() {
00007     printf("Hello World!\n");   
00008  
00009     mkdir("/sd/mydir", 0777);
00010     
00011     FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
00012     if(fp == NULL) {
00013         error("Could not open file for write\n");
00014     }
00015     fprintf(fp, "Hello fun SD Card World!");
00016     fclose(fp); 
00017  
00018     printf("Goodbye World!\n");
00019 }