#define BLYNK_TEMPLATE_ID "TMPL608a_hhrZ"
#define BLYNK_TEMPLATE_NAME "Pengendalian LED"
#define BLYNK_AUTH_TOKEN "oFMLx1ikqcf0MtIExqvUaw5RnlqOVZrF"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "oFMLx1ikqcf0MtIExqvUaw5RnlqOVZrF";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
#define relay 2
int SW_relay = 0;
BLYNK_WRITE(V1)
{
SW_relay = param.asInt();
if (SW_relay ==1){
digitalWrite(relay, HIGH);
Serial.println("Relay Terbuka");
Blynk.virtualWrite(V1, HIGH);
}else{
digitalWrite(relay, LOW);
Serial.println("Relay Tertutup");
Blynk.virtualWrite(V1, LOW);
}
}
void setup() {
Serial.begin(115200);
pinMode(relay, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
timer.run();
}