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 DHT11
main.cpp@2:279a4193cde4, 2020-03-02 (annotated)
- Committer:
- marvas
- Date:
- Mon Mar 02 11:01:21 2020 +0000
- Revision:
- 2:279a4193cde4
- Parent:
- 1:2baac9785cda
- Child:
- 3:d8b420b7c7ff
SD KART OKUMA Pinler revize edildi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marvas | 0:ea4c45f3cff7 | 1 | #include "mbed.h" |
marvas | 0:ea4c45f3cff7 | 2 | #include "SDFileSystem.h" |
marvas | 2:279a4193cde4 | 3 | SDFileSystem sd(D12, D11, D13, D10, "sd"); // mosi, miso, sclk, cs(scl) |
marvas | 0:ea4c45f3cff7 | 4 | unsigned char c; |
marvas | 0:ea4c45f3cff7 | 5 | |
marvas | 0:ea4c45f3cff7 | 6 | int main() |
marvas | 0:ea4c45f3cff7 | 7 | { |
marvas | 2:279a4193cde4 | 8 | mkdir("/sd", 0777); |
marvas | 0:ea4c45f3cff7 | 9 | //mkdir klasör oluşturur. |
marvas | 0:ea4c45f3cff7 | 10 | //0777 dosyaya veri yazıp okumayı etkinleştirir. |
marvas | 0:ea4c45f3cff7 | 11 | while(1) { |
marvas | 1:2baac9785cda | 12 | wait_ms(500); |
marvas | 2:279a4193cde4 | 13 | FILE *fp = fopen("/sd/belge.txt", "a"); |
marvas | 0:ea4c45f3cff7 | 14 | /* a - dosyanın içerisine var olan verinin yanına ekleme yapar |
marvas | 0:ea4c45f3cff7 | 15 | r - Dosyadan okuma yapar |
marvas | 0:ea4c45f3cff7 | 16 | w - Dosyadan verileri siler yeni veriyi ekler. |
marvas | 0:ea4c45f3cff7 | 17 | */ |
marvas | 0:ea4c45f3cff7 | 18 | if(fp == NULL) { |
marvas | 0:ea4c45f3cff7 | 19 | error("Yazma icin dosya acilamadi \n"); |
marvas | 0:ea4c45f3cff7 | 20 | printf("Yazma icin dosya acilamadi \n"); |
marvas | 0:ea4c45f3cff7 | 21 | } |
marvas | 0:ea4c45f3cff7 | 22 | |
marvas | 0:ea4c45f3cff7 | 23 | else { |
marvas | 0:ea4c45f3cff7 | 24 | //Sd karta yazar |
marvas | 1:2baac9785cda | 25 | fprintf(fp, "ismek fatih bilisim okulu\n"); |
marvas | 0:ea4c45f3cff7 | 26 | fclose(fp); //Dosya kapat |
marvas | 0:ea4c45f3cff7 | 27 | // |
marvas | 2:279a4193cde4 | 28 | FILE *fpr = fopen("/sd/belge.txt", "r"); |
marvas | 0:ea4c45f3cff7 | 29 | //Okunacak dosya seçildi |
marvas | 0:ea4c45f3cff7 | 30 | |
marvas | 0:ea4c45f3cff7 | 31 | //file end of. Okuma işlemi bitene kadar devam et. |
marvas | 0:ea4c45f3cff7 | 32 | //Dosya sonuna kadar okumaya devam et. |
marvas | 0:ea4c45f3cff7 | 33 | while (!feof(fpr)) { |
marvas | 0:ea4c45f3cff7 | 34 | c=fgetc(fpr); |
marvas | 0:ea4c45f3cff7 | 35 | printf("%c",c); |
marvas | 0:ea4c45f3cff7 | 36 | } |
marvas | 0:ea4c45f3cff7 | 37 | fclose(fpr); |
marvas | 0:ea4c45f3cff7 | 38 | } |
marvas | 0:ea4c45f3cff7 | 39 | } |
marvas | 0:ea4c45f3cff7 | 40 | } |