#define BLYNK_TEMPLATE_ID "TMPL6jH_yaL-7"
#define BLYNK_TEMPLATE_NAME "digital clock"
#define BLYNK_AUTH_TOKEN "cAualTG29A3jIsVFhCmm1dfBnVIpMm99"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFi.h>
#include <BlynkSimpleWifi.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Sipudan";
char pass[] = "clarissa02";
BlynkTimer timer;
WidgetRTC rtc;
// Digital clock display of the time
void clockDisplay()
{
// You can call hour(), minute(), ... at any time
// Please see Time library examples for details
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentDate = String(day()) + "/" + month() + "/" + year();
Serial.print("Current time: ");
Serial.print(currentTime);
Serial.print(" ");
Serial.print(currentDate);
Serial.println();
// Send time to the App
Blynk.virtualWrite(V1, currentTime);
// Send date to the App
Blynk.virtualWrite(V2, currentDate);
if (hour()==8 && minute()==29 &&second()<2){
Serial.println("waktunya LED ON");
digitalWrite(2,0);
}
else if (hour()==8 && minute()==30 &&second()<2){
Serial.println("waktunya LED OFF");
digitalWrite(2,0);
}
}
BLYNK_CONNECTED() {
// Synchronize time on connection
rtc.begin();
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
// Other Time library functions can be used, like:
// timeStatus(), setSyncInterval(interval)...
// Read more: http://www.pjrc.com/teensy/td_libs_Time.html
setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
// Display digital clock every 10 seconds
timer.setInterval(1000L, clockDisplay);
pinMode(2,OUTPUT);
digitalWrite(2,0);
}
void loop()
{
Serial.println("Connecting to WiFi...");
Blynk.run();
timer.run();
}