Clock
Dependencies: 4DGL-uLCD-SE EthernetInterface NTPClient TextLCD mbed PinDetect SDFileSystem wave_player mbed-rtos
Fork of Internet_LCD_Clock by
Revision 0:5c5226aac712, committed 2012-04-12
- Comitter:
- 4180_1
- Date:
- Thu Apr 12 01:44:02 2012 +0000
- Child:
- 1:09fcc9b81f23
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetNetIf.lib Thu Apr 12 01:44:02 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Internet_LCD_Clock.cpp Thu Apr 12 01:44:02 2012 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "NTPClient.h" +#include "TextLCD.h" +// Internet of Things clock example: LCD time is set via internet NTP time server +TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d0-d3 +EthernetNetIf eth; +NTPClient ntp; + +int main() { +//system time structure + time_t ctTime; + //clear LCD + lcd.cls(); + // lcd.printf prints to LCD display; + lcd.printf("Get IP addr..."); + EthernetErr ethErr = eth.setup(); + //Get an Internet IP address using DHCP + if (ethErr) { + //error or timeout getting an IP address + printf("Error %d in setup.\n\r", ethErr); + lcd.cls(); + lcd.printf("Network Error \n\r %d",ethErr); + return -1; + } + lcd.cls(); + ctTime = time(NULL); + lcd.printf("Reading Time...\n\r"); + //specify time server URL + Host server(IpAddr(), 123, "0.uk.pool.ntp.org"); + //Read time from server + ntp.setTime(server); + ctTime = time(NULL); + lcd.printf("Time set"); + //Delay for human time to read LCD display + wait(1); + while (1) { + // loop and periodically update the LCD's time display + lcd.cls(); + ctTime = time(NULL); + lcd.printf("UTC: %s", ctime(&ctTime)); + wait(.25); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Thu Apr 12 01:44:02 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Thu Apr 12 01:44:02 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 12 01:44:02 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da