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:b960f9d7b0b3
- Parent:
- 0:bdbd3d6fc5d5
diff -r e4d7342be507 -r b960f9d7b0b3 main.cpp
--- a/main.cpp Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp Sun Feb 02 02:45:09 2020 +0000
@@ -1,19 +1,34 @@
#include "mbed.h"
#include "SDFileSystem.h"
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+//SDFileSystem sd(mosi, miso, sclk, cs, "sd")
+SDFileSystem sd( PB_5, PB_4, PB_3, PB_6, "sd"); // the pinout on the mbed Cool Components workshop board
+DigitalOut myled(PC_6);
-int main() {
- printf("Hello World!\n");
-
+void blink(float on, float off) {
+ myled = 1; // LED is ON
+ wait(on); // 1 sec
+ myled = 0; // LED is OFF
+ wait(off); // 1 sec
+}
+int main() {
+ blink(0.1, 1);
mkdir("/sd/mydir", 0777);
+ blink(0.1, 1);
FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+
+ blink(0.1, 1);
if(fp == NULL) {
error("Could not open file for write\n");
}
+
+ blink(0.1, 1);
fprintf(fp, "Hello fun SD Card World!");
+
+ blink(0.1, 1);
fclose(fp);
+
+ blink(0.1, 1);
- printf("Goodbye World!\n");
}