Bob B
/
Set_Clock
Set clock using unix time and included functions in mbed.h. Includes link to Unix time converter.
main.cpp@0:680c4f0d8664, 2010-07-19 (annotated)
- Committer:
- rumbleweed
- Date:
- Mon Jul 19 21:30:25 2010 +0000
- Revision:
- 0:680c4f0d8664
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rumbleweed | 0:680c4f0d8664 | 1 | #include "mbed.h" |
rumbleweed | 0:680c4f0d8664 | 2 | #include "TextLCD.h" |
rumbleweed | 0:680c4f0d8664 | 3 | |
rumbleweed | 0:680c4f0d8664 | 4 | |
rumbleweed | 0:680c4f0d8664 | 5 | TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3 |
rumbleweed | 0:680c4f0d8664 | 6 | |
rumbleweed | 0:680c4f0d8664 | 7 | Serial pc (USBTX,USBRX); |
rumbleweed | 0:680c4f0d8664 | 8 | |
rumbleweed | 0:680c4f0d8664 | 9 | int main() { |
rumbleweed | 0:680c4f0d8664 | 10 | // replace unix time beow with current unix time from http://unixtime-converter.com |
rumbleweed | 0:680c4f0d8664 | 11 | set_time(1279538160); |
rumbleweed | 0:680c4f0d8664 | 12 | |
rumbleweed | 0:680c4f0d8664 | 13 | while (1) { |
rumbleweed | 0:680c4f0d8664 | 14 | time_t seconds = time(NULL); |
rumbleweed | 0:680c4f0d8664 | 15 | lcd.cls(); |
rumbleweed | 0:680c4f0d8664 | 16 | printf("\n\rTime Date=\n\r %s", ctime(&seconds)); |
rumbleweed | 0:680c4f0d8664 | 17 | |
rumbleweed | 0:680c4f0d8664 | 18 | lcd.printf("Time %s",ctime(&seconds)); |
rumbleweed | 0:680c4f0d8664 | 19 | wait(3); |
rumbleweed | 0:680c4f0d8664 | 20 | } |
rumbleweed | 0:680c4f0d8664 | 21 | } |
rumbleweed | 0:680c4f0d8664 | 22 | |
rumbleweed | 0:680c4f0d8664 | 23 |