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.
Diff: main.cpp
- Revision:
- 0:58ddbe75c659
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jan 08 16:23:10 2021 +0000
@@ -0,0 +1,36 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE_MS 500
+
+
+int main() {
+
+ // get the current time from the terminal
+ struct tm t;
+ printf("Enter current date and time:\n");
+ printf("2021 01 08 16 01 00[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);
+ }
+}