Reading Analog Ports and Saving in a micro SD CARD with the KL25z

Dependencies:   SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by Neil Thiessen

Revision:
19:ae979143c796
Parent:
17:e5b7469082c8
Child:
20:ec1c4f02d50e
diff -r 0999ca8699d8 -r ae979143c796 main.cpp
--- a/main.cpp	Thu Nov 26 16:25:46 2015 +0000
+++ b/main.cpp	Tue Dec 08 16:14:07 2015 +0000
@@ -79,8 +79,22 @@
         //Wait for the button to be pressed
         while(button);
 
+        //Make sure a card is present
+        if (!sd.card_present()) {
+            printf("\nNo card present!\n");
+            continue;
+        }
+
+        //Try to mount the SD card
+        printf("\nMounting SD card...");
+        if (sd.mount() != 0) {
+            printf("failed!\n");
+            continue;
+        }
+        printf("success!\n");
+
         //Display the card type
-        printf("\nCard type: ");
+        printf("\tCard type: ");
         SDFileSystem::CardType cardType = sd.card_type();
         if (cardType == SDFileSystem::CARD_NONE)
             printf("None\n");
@@ -93,17 +107,9 @@
         else
             printf("Unknown\n");
 
-        //Try to mount the SD card
-        printf("Mounting SD card...");
-        if (sd.mount() != 0) {
-            printf("failed!\n");
-            continue;
-        }
-        printf("success!\n");
-
         //Display the card capacity
-        printf("Sectors: %llu\n", sd.disk_sectors());
-        printf("Capacity: %.1fMB\n", sd.disk_sectors() / 2048.0);
+        printf("\tSectors: %llu\n", sd.disk_sectors());
+        printf("\tCapacity: %.1fMB\n", sd.disk_sectors() / 2048.0);
 
         /*//Format the card
         printf("Formatting SD card...");