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 sd_kart_yazma_okma
main.cpp
- Committer:
- marvas
- Date:
- 2020-03-02
- Revision:
- 2:279a4193cde4
- Parent:
- 1:2baac9785cda
- Child:
- 3:d8b420b7c7ff
File content as of revision 2:279a4193cde4:
#include "mbed.h"
#include "SDFileSystem.h"
SDFileSystem sd(D12, D11, D13, D10, "sd"); // mosi, miso, sclk, cs(scl)
unsigned char c;
int main()
{
mkdir("/sd", 0777);
//mkdir klasör oluşturur.
//0777 dosyaya veri yazıp okumayı etkinleştirir.
while(1) {
wait_ms(500);
FILE *fp = fopen("/sd/belge.txt", "a");
/* a - dosyanın içerisine var olan verinin yanına ekleme yapar
r - Dosyadan okuma yapar
w - Dosyadan verileri siler yeni veriyi ekler.
*/
if(fp == NULL) {
error("Yazma icin dosya acilamadi \n");
printf("Yazma icin dosya acilamadi \n");
}
else {
//Sd karta yazar
fprintf(fp, "ismek fatih bilisim okulu\n");
fclose(fp); //Dosya kapat
//
FILE *fpr = fopen("/sd/belge.txt", "r");
//Okunacak dosya seçildi
//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);
}
}
}