Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem
Diff: main.cpp
- Revision:
- 2:9171c2347ef0
- Parent:
- 0:bdbd3d6fc5d5
diff -r e4d7342be507 -r 9171c2347ef0 main.cpp
--- a/main.cpp Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp Sat Dec 29 06:38:26 2018 +0000
@@ -1,19 +1,35 @@
#include "mbed.h"
#include "SDFileSystem.h"
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
-
+SDFileSystem sd(D4, D5, D3, D1, "sd"); // mosi, miso, sclk, cs
+ Serial pc(USBTX,USBRX);
+ unsigned char c;
+
int main() {
- printf("Hello World!\n");
+ pc.printf("Karta yazma ve okuma islem basladi \n");
- mkdir("/sd/mydir", 0777);
+ mkdir("/sd", 0777);
+//mkdir klasör oluşturur.
+//0777 dosyaya veri yazıp okumayı etkinleştirir.
- FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+ FILE *fp = fopen("/sd/ornek.txt", "w");
if(fp == NULL) {
- error("Could not open file for write\n");
+ error("Yazma icin dosya acilamadi \n");
}
- fprintf(fp, "Hello fun SD Card World!");
- fclose(fp);
+ fprintf(fp, "Merhaba. Bu yazi Sd karta yazilacak!");
+ fclose(fp); //Dosya kapat
+
+ pc.printf("Yazma islemi bitti! \n");
+
+ pc.printf("Okuma islemi basladi! \n");
+ FILE *fpr = fopen("/sd/ornek.txt", "r");
+ //Okunacak dosya seçildi
- printf("Goodbye World!\n");
+ //file end of. Okuma işlemi bitene kadar devam et.
+ //Dosya sonuna kadar okumaya devam et.
+ while (!feof(fpr)){
+ c=fgetc(fpr);
+ printf("%c",c);
+ }
+ fclose(fpr);
}