#include #include #include #include #include #include //handles sending and receiving of UDP packages #include // provides ESP8266 specific Wi-Fi routines we are calling to connect to network #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_MOSI 13 #define OLED_CLK 14 #define OLED_DC 4 #define OLED_CS 15 #define OLED_RESET 0 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT,OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); const char *ssid = "*********"; const char *password = "*********"; WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800,60000); String arr_days[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; String date_time; // You can specify the time server pool and the offset (in seconds, can be // changed later with setTimeOffset() ). Additionaly you can specify the // update interval (in milliseconds, can be changed using setUpdateInterval() ). void setup(){ Serial.begin(115200); WiFi.begin(ssid, password); while ( WiFi.status() != WL_CONNECTED ) { delay ( 500 ); Serial.print ( "." ); } if(!oled.begin(SSD1306_SWITCHCAPVCC)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } oled.clearDisplay(); oled.setTextSize(1); // Draw 2X-scale text oled.setTextColor(WHITE); oled.setCursor(5, 2); oled.println("AYUBOWAN.!"); oled.println("Prabuddha"); oled.println(" Srimal"); oled.display(); delay(3000); timeClient.begin(); } void loop(){ timeClient.update(); oled.clearDisplay(); Serial.println(timeClient.getFormattedTime()); oled.setTextSize(3); // Draw 2X-scale text oled.setTextColor(WHITE); oled.setCursor(0, 2); int hh = timeClient.getHours(); int mm = timeClient.getMinutes(); int ss = timeClient.getSeconds(); if(hh>12) { hh=hh-12; oled.print(hh); oled.print(":"); oled.print(mm); oled.print(":"); oled.println("pm"); } else { oled.print(hh); oled.print(":"); oled.print(mm); oled.print(":"); oled.println("am"); } int day = timeClient.getDay(); oled.println(""+arr_days[day]+""); oled.display(); // Show initial text } //@ApePanthiya ICT