#define BLYNK_TEMPLATE_ID "TMPL6eXqb9dxz"
#define BLYNK_TEMPLATE_NAME "kontrol relay"
#define BLYNK_AUTH_TOKEN "PozN1TJF-9Ek38DPA5-Jau1vnKTZJrj3"
#include <WiFi.h>
#include<WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "PozN1TJF-9Ek38DPA5-Jau1vnKTZJrj3";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer ;
#define relay 2
int SW_relay = 0;
BLYNK_WRITE(V0)
{
SW_relay = param.asInt();
if (SW_relay ==1){
digitalWrite(relay, HIGH);
Serial.println("Relay terbuka");
Blynk.virtualWrite(V0, HIGH);
}else{
digitalWrite(relay, LOW);
Serial.println("relay terbuka");
Blynk.virtualWrite(V0, LOW);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(relay, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
timer.run();
}