mbed workshop intro + cansat examples
Diff: RTC1.cpp
- Revision:
- 0:f309f06aeec7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTC1.cpp Thu May 10 21:14:34 2012 +0000 @@ -0,0 +1,14 @@ +#include "mbed.h" + +int main() { + time_t seconds; + char buf[32]; + + seconds = (((2011 - 1969) * 365 + (2011 - 1968) / 4) + + 31 + 29 + 31 + 30 + 26) * 24 * 3600 + + 15 * 3600 + 14 * 60; + set_time(seconds); + seconds = time(NULL); + strftime(buf, sizeof(buf), "%x %X", localtime(&seconds)); + printf("mbed rtc = %s (timestamp = %d)\n", buf, seconds); +} \ No newline at end of file