7.3 Eingabe der Zeit mittels Serieller Schnittstelle und Ausgabe mittels printf.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
stefan1691
Date:
Sun Feb 22 12:50:44 2015 +0000
Commit message:
7.3 Eingabe der Zeit mittels Serieller Schnittstelle und Ausgabe mittels printf.

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 22 12:50:44 2015 +0000
@@ -0,0 +1,29 @@
+/** 7.3 Eingabe der Zeit mittels Serieller Schnittstelle und Ausgabe mittels printf.
+ * Beispiel von http://developer.mbed.org/blog/entry/103/
+*/
+#include "mbed.h"
+
+int main()
+{
+    // get the current time from the terminal
+    struct tm t;
+    printf("Enter current date and time:\n");
+    printf("YYYY MM DD HH MM SS[enter]\n");
+    scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday
+          , &t.tm_hour, &t.tm_min, &t.tm_sec);
+
+    // adjust for tm structure required values
+    t.tm_year = t.tm_year - 1900;
+    t.tm_mon = t.tm_mon - 1;
+
+    // set the time
+    set_time(mktime(&t));
+
+    // display the time
+    while(1) 
+    {
+        time_t seconds = time(NULL);
+        printf("Time as a basic string = %s", ctime(&seconds));
+        wait(1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 22 12:50:44 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file