Difference between revisions of "WeMOS: NTP Jam Digital 7 Segmen Display"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (Created page with " #include <NTPClient.h> #include <ESP8266WiFi.h> #include <WiFiUdp.h> #include <Wire.h> #include <TM1650.h> const char *ssid = "HUAWEI-1A73"; const char *password...") |
Onnowpurbo (talk | contribs) |
||
Line 5: | Line 5: | ||
#include <TM1650.h> | #include <TM1650.h> | ||
− | const char *ssid = " | + | const char *ssid = "ssid"; |
− | const char *password = " | + | const char *password = "password"; |
const long utcOffsetInSeconds = 3600; | const long utcOffsetInSeconds = 3600; | ||
Line 33: | Line 33: | ||
void loop() { | void loop() { | ||
− | char waktu[]; | + | char waktu[5]; |
timeClient.update(); | timeClient.update(); | ||
Revision as of 11:28, 12 February 2020
#include <NTPClient.h> #include <ESP8266WiFi.h> #include <WiFiUdp.h> #include <Wire.h> #include <TM1650.h> const char *ssid = "ssid"; const char *password = "password"; const long utcOffsetInSeconds = 3600; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; // Define NTP Client to get time WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds); TM1650 d; void setup(){ Serial.begin(115200); Wire.begin(); //Join the bus as master WiFi.begin(ssid, password); while ( WiFi.status() != WL_CONNECTED ) { delay ( 500 ); Serial.print ( "." ); } timeClient.begin(); d.init(); }
void loop() { char waktu[5]; timeClient.update(); Serial.print(daysOfTheWeek[timeClient.getDay()]); Serial.print(", "); Serial.print(timeClient.getHours()+6); Serial.print(":"); Serial.print(timeClient.getMinutes()); Serial.print(":"); Serial.println(timeClient.getSeconds()); //Serial.println(timeClient.getFormattedTime()); itoa( 100*(timeClient.getHours()+6) + timeClient.getMinutes(), waktu, 10); d.displayOn(); d.displayString(waktu); delay(1000); for (int i = 0; i<5; i++) { d.setDot(i,true); delay(100); d.setDot(i,false); delay(100); } }