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
Revision 2:9171c2347ef0, committed 2018-12-29
- Comitter:
- marvas
- Date:
- Sat Dec 29 06:38:26 2018 +0000
- Parent:
- 1:e4d7342be507
- Commit message:
- sd kart okuma ve yazma
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
}
--- a/mbed.bld Tue May 16 05:18:55 2017 +0000 +++ b/mbed.bld Sat Dec 29 06:38:26 2018 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file