LPC1768_AppBoard_Internet_LCD_Clock
Dependencies: C12832_lcd DNSResolver EthernetNetIf NTPClientMin mbed
Fork of Internet_LCD_Clock by
LPC1768_AppBoard_Internet_LCD_Clock.cpp
- Committer:
- joinamruta
- Date:
- 2014-02-13
- Revision:
- 3:8d177b351165
- Parent:
- 2:e018257b953a
File content as of revision 3:8d177b351165:
#include "mbed.h" #include "EthernetNetIf.h" #include "NTPClient.h" #include "C12832_lcd.h" // Internet of Things clock example: LCD time is set via internet NTP time server EthernetNetIf eth; NTPClient ntp; C12832_LCD lcd; int main() { //system time structure time_t ctTime; //clear LCD lcd.cls(); lcd.locate(0,0); // 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 lcd.cls(); lcd.printf("Network Error \n\r %d",ethErr); return -1; } lcd.cls(); lcd.locate(0,0); lcd.printf("Reading Time...\n\r"); //specify time server URL Host server(IpAddr(), 123, "0.us.pool.ntp.org"); //Read time from server ntp.setTime(server); lcd.cls(); lcd.locate(0,0); 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(); lcd.locate(0,0); ctTime = time(NULL); lcd.printf("UTC: %s", ctime(&ctTime)); wait(.25); } }