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