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.
main.cpp
00001 // Example to setup the Real-Time Clock from a terminal, sford 00002 00003 #include "mbed.h" 00004 00005 int main() { 00006 00007 // get the current time from the terminal 00008 struct tm t; 00009 printf("Enter current date and time:\n"); 00010 printf("YYYY MM DD HH MM SS[enter]\n"); 00011 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); 00012 00013 // adjust for tm structure required values 00014 t.tm_year = t.tm_year - 1900; 00015 t.tm_mon = t.tm_mon - 1; 00016 00017 // set the time 00018 set_time(mktime(&t)); 00019 00020 // display the time 00021 while(1) { 00022 time_t seconds = time(NULL); 00023 printf("Time as a basic string = %s", ctime(&seconds)); 00024 wait(1); 00025 } 00026 }
Generated on Fri Jul 15 2022 03:58:42 by
1.7.2